local extension = Package:new("thbattle")
extension.extensionName = "thbattle"

local THB_Utility = require "packages/thbattle/THB_Utility"

Fk:loadTranslationTable {
  ["tho"] = "东方",
  ["thbattle_fuka"] = "<br><font color='grey'><b>#符卡</b><br/>符斗祭对锦囊牌的称呼<br>",
  ["@@Protect_skillInvoke-phase"] = "保护",
}
local U = require "packages/utility/utility"

Fk:appendKingdomMap("god", { "tho" })


--保护机制之摸牌数量不能多于35
local Protect_drawNcards = fk.CreateTriggerSkill {
  name = "#Protect_drawNcards",
  mute = true,
  global = true,
  priority = 0.1,
  frequency = Skill.Compulsory,
  events = { fk.BeforeDrawCard },
  can_trigger = function(self, event, target, player, data)
    return target == player and data.who == player and data.num > 35
  end,
  on_use = function(self, event, target, player, data)
    player.room:doBroadcastNotify("ShowToast", "博丽灵梦：摸牌异变！"..Fk:translate(player.general).."的牌实在是太多了，削弱摸牌数量")
    data.num = 35
  end
}

--保护机制之技能阶段发动次数不能大于40
local Protect_skillEffect = fk.CreateTriggerSkill {
  name = "#Protect_skillEffect",
  mute = true,
  global = true,
  priority = 100,
  frequency = Skill.Compulsory,
  events = { fk.SkillEffect },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(data) and data:isPlayerSkill(target) and data.visible 
      and player:usedSkillTimes(data.name,Player.HistoryPhase)>40
  end,
  on_use = function(self, event, target, player, data)
    player.room:doBroadcastNotify("ShowToast", "博丽灵梦：技能异变！"..Fk:translate(player.general).."的技能发动的实在是太频繁了，封魔全部技能！")
    local room = player.room
    for _, skill in pairs(player.player_skills) do
      if skill:isPlayerSkill(player) and skill.visible then
        room:invalidateSkill(player,skill.name,"-phase")
      end
    end
    room:setPlayerMark(player,"@!Protect_skillEffect-phase",1)
  end
}
Fk:addSkill(Protect_skillEffect)
Fk:addSkill(Protect_drawNcards)


-- 七色的人偶使 爱丽丝 体力：4

-- 人偶爆弹：每当你装备区的牌被其他角色获得或弃置时，你可以弃置其一张牌。若此法弃置的牌为该角色获得的牌，你对其造成1点伤害。

-- 小小军势：出牌阶段结束时，你可以重铸一张装备牌，然后发动对应的效果：
-- >> 武器：视为对一名其他角色使用了弹幕。
-- >> 防具：令一名角色回复1点体力。
-- >> 饰品：摸一张牌并跳过弃牌阶段。
-- >> UFO：视为使用一张人型操控。

local thbattle__ailisi = General:new(extension, "thbattle__ailisi", "tho", 4, 4, General.Male)

local thbattle__ailisi_renoubaodan = fk.CreateTriggerSkill {
  name = "thbattle__ailisi_renoubaodan",
  events = { fk.AfterCardsMove },
  anim_type = "masochism",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) then
      for _, move in ipairs(data) do
        if move.proposer and move.proposer ~= player.id and not player.room:getPlayerById(move.proposer):isNude()
            and move.from and move.from == player.id and
            ((move.to and move.to ~= player.id) or (move.to == nil and (move.toArea == Card.DiscardPile or move.toArea == Card.Processing))) then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.PlayerEquip then
              self.cost_data = move.proposer
              return true
            end
          end
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targetCards_ids = {}
    for _, move in ipairs(data) do
      if move.proposer and move.proposer ~= player.id and move.from and move.from == player.id and
          ((move.to and move.to ~= player.id) or (move.to == nil and move.toArea == Card.DiscardPile)) then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerEquip then
            table.insertIfNeed(targetCards_ids, info.cardId)
          end
        end
      end
    end
    local target_p = room:getPlayerById(self.cost_data)
    local cids = room:askForCardChosen(player, target_p, "he", self.name)
    room:throwCard(cids, self.name, target_p, player)
    if cids and #targetCards_ids > 0 then
      for index, cid in ipairs(targetCards_ids) do
        if cid == cids then
          room:damage({
            from = player,
            to = room:getPlayerById(self.cost_data),
            damage = 1,
            skillName = self.name,
          })
        end
      end
    end
  end,
}

local thbattle__ailisi_xiaoxiaojunshi = fk.CreateTriggerSkill {
  name = "thbattle__ailisi_xiaoxiaojunshi",
  prompt = "#thbattle__ailisi_xiaoxiaojunshi",
  mute = true,
  events = { fk.EventPhaseEnd, fk.EventPhaseChanging },
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(self) then
      if event == fk.EventPhaseEnd then
        return player.phase == Player.Play and table.find(player:getCardIds("he"), function(cid)
          return Fk:getCardById(cid).type == Card.TypeEquip
        end)
      elseif event == fk.EventPhaseChanging then
        return data.to == Player.Discard and player:getMark("thbattle__ailisi_xiaoxiaojunshi-skipDiscard") > 0
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.EventPhaseEnd then
      local targetPlayer
      local discard = room:askForDiscard(player, 1, 1, true, self.name, false, '.|.|.|.|.|equip',
        "#thbattle__ailisi_xiaoxiaojunshi-choose_card")
      if #discard > 0 then
        room:recastCard(discard, player, self.name)
        local discard_card = Fk:getCardById(discard[1]).sub_type
        if discard_card == Card.SubtypeArmor then
          room:notifySkillInvoked(player, self.name, "support")
          player:broadcastSkillInvoke(self.name, 3)
          targetPlayer = room:askForChoosePlayers(player, table.map(room.alive_players, function(p)
            if p:isWounded() then
              return p.id
            else
              return nil
            end
          end), 1, 1, "#thbattle__ailisi_xiaoxiaojunshi-recover", self.name, true)
          if #targetPlayer > 0 then
            room:recover({
              who = room:getPlayerById(targetPlayer[1]),
              num = 1,
              skillName = self.name,
              recoverBy = player,
            })
          end
        elseif discard_card == Card.SubtypeTreasure then
          room:notifySkillInvoked(player, self.name, "drawcard")
          player:broadcastSkillInvoke(self.name, 4)
          player:drawCards(1, self.name)
          room:addPlayerMark(player, "thbattle__ailisi_xiaoxiaojunshi-skipDiscard")
        elseif discard_card == Card.SubtypeWeapon then
          room:notifySkillInvoked(player, self.name, "offensive")
          player:broadcastSkillInvoke(self.name, 1)
          room:useCard({
            from = player.id,
            tos = table.map(room:getOtherPlayers(player), function(p, index, array)
              return { p.id }
            end),
            card = Fk:cloneCard("danmu__slash"),
            extraUse = true,
          })
        elseif discard_card == Card.SubtypeOffensiveRide or discard_card == Card.SubtypeDefensiveRide then
          room:notifySkillInvoked(player, self.name, "control")
          player:broadcastSkillInvoke(self.name, 2)
          local targets = table.filter(room:getOtherPlayers(player), function(p, index, array)
            if #p:getCardIds("e") > 0 and table.find(p:getCardIds("e"), function(cid)
                  return Fk:getCardById(cid).sub_type == Card.SubtypeWeapon
                end) then
              return true
            end
          end)
          if #targets > 0 then
            local collateral = Fk:cloneCard("collateral")
            local p_ids = room:askForChoosePlayers(player, table.map(
              targets,
              Util.IdMapper
            ), 1, 1, "#thbattle__ailisi_xiaoxiaojunshi-recover", self.name)
            if #p_ids > 0 then
              local p = room:getPlayerById(p_ids[1])
              if player:isAlive() and player:canUseTo(collateral, p) then
                local filter_target = table.filter(
                  room:getOtherPlayers(p),
                  function(to)
                    return p:inMyAttackRange(to)
                  end
                )
                if #filter_target > 0 then
                  local availableTargets = table.map(
                    filter_target,
                    Util.IdMapper
                  )

                  if #availableTargets > 0 then
                    local tos = room:askForChoosePlayers(player, availableTargets, 1, 1,
                      "#thbattle__ailisi_xiaoxiaojunshi-jiedao", self.name)
                    if #tos > 0 then
                      room:useCard {
                        from = player.id,
                        tos = { { p.id }, { tos[1] } },
                        card = collateral,
                        skillName = self.name
                      }
                    end
                  end
                end
              end
            end
          end
        end
      end
    else
      room:removePlayerMark(player, "thbattle__ailisi_xiaoxiaojunshi-skipDiscard")
      return true
    end
  end
}

thbattle__ailisi:addSkill(thbattle__ailisi_renoubaodan)
thbattle__ailisi:addSkill(thbattle__ailisi_xiaoxiaojunshi)
Fk:loadTranslationTable {
  ["thbattle__ailisi"] = "爱丽丝",
  ["#thbattle__ailisi"] = "七色的人偶使",
  ["~thbattle__ailisi"] = "变，变态！放开那个人偶！",
  ["designer:thbattle__ailisi"] = "Rem",
  ["illustrator:thbattle__ailisi"] = "霏茶",
  ["cv:thbattle__ailisi"] = "小舞",


  ["thbattle__ailisi_renoubaodan"] = "人偶爆弹",
  ["$thbattle__ailisi_renoubaodan1"] = "我有预感，你要炸了！💣",
  ["$thbattle__ailisi_renoubaodan2"] = "我的人偶，是你可以碰的吗？( o｀ω′)ノ。",
  [":thbattle__ailisi_renoubaodan"] = "每当你装备区的牌被其他角色获得或弃置时，你可以弃置其一张牌。若此法弃置的牌为该角色获得的牌，你对其造成1点伤害。",

  ["thbattle__ailisi_xiaoxiaojunshi"] = "小小军势",
  ["#thbattle__ailisi_xiaoxiaojunshi"] = "小小军势：重铸一张装备牌执行不同的效果",
  ["$thbattle__ailisi_xiaoxiaojunshi1"] = "进攻！🗡",
  ["$thbattle__ailisi_xiaoxiaojunshi2"] = "乖乖站好！",
  ["$thbattle__ailisi_xiaoxiaojunshi3"] = "需要支援！👨‍💼",
  ["$thbattle__ailisi_xiaoxiaojunshi4"] = "帮我拿着~\\(￣︶￣*\\))",

  [":thbattle__ailisi_xiaoxiaojunshi"] = "出牌阶段结束时，你可以重铸一张装备牌，然后发动对应的效果：<br/>" ..
      "<font color='red'>>> 武器：</font>视为对一名其他角色使用了弹幕。<br/>" ..
      "<font color='red'>>> 防具：</font>令一名角色回复1点体力。<br/>" ..
      "<font color='red'>>> 饰品：</font>摸一张牌并跳过弃牌阶段。<br/>" ..
      "<font color='red'>>> UFO：</font>视为使用一张【人型操控】。<br/>",
  ["#thbattle__ailisi_xiaoxiaojunshi-choose_card"] = "小小军势：请选择重铸一张装备",
  ["#thbattle__ailisi_xiaoxiaojunshi-recover"] = "小小军势：请选择一名角色回复一点体力",
  ["#thbattle__ailisi_xiaoxiaojunshi-jiedao"] = "小小军势：请选择一名角色对其使用借刀杀人",

}



--   凶兆的黑喵 橙 体力：4

--   飞翔韦驮天：出牌阶段限一次，你使用弹幕或单体符卡时，可以额外指定一个目标。
--   >> 此处不能使用人形操控

--   式神：限定技，出牌阶段，你可以令一名其他角色选择一项：>> 摸两张牌，>> 回复1点体力。
--   直到下次你的回合开始时，你与其可以在出牌阶段对对方攻击范围内的角色使用弹幕。

--   （画师：和茶，CV：shourei小N）
local thbattle__cheng = General:new(extension, "thbattle__cheng", "tho", 4, 4, 2)

local thbattle__cheng_feixiang = fk.CreateTriggerSkill {
  name = "thbattle__cheng_feixiang",
  anim_type = "offensive",
  events = { fk.AfterCardTargetDeclared },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Play and
        player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
        and data.card and data.card.multiple_targets ~= true and
        (data.card.trueName == "slash" or (data.card:isCommonTrick() and data.card.trueName ~= "collateral"))
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if room:askForSkillInvoke(player, self.name) then
      local targets = {}
      for _, p in ipairs(room:getOtherPlayers(player)) do
        if not table.contains(TargetGroup:getRealTargets(data.tos), p.id) and not player:isProhibited(p, data.card) then
          if player:inMyAttackRange(p) and data.card.trueName == "slash" then
            table.insertIfNeed(targets, p.id)
          elseif data.card:isCommonTrick() and data.card.trueName ~= "collateral" then
            table.insertIfNeed(targets, p.id)
          end
        end
      end
      if #targets > 0 then
        local tos = room:askForChoosePlayers(player, targets, 1, 1, "#thbattle__cheng_feixiang-choose", self
          .name, true)
        if #tos > 0 then
          self.cost_data = tos[1]
          return true
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    table.insert(data.tos, { self.cost_data })
  end
}

local thbattle__cheng_shishen = fk.CreateActiveSkill {
  name = "thbattle__cheng_shishen",
  anim_type = "big",
  frequency = Skill.Limited,
  target_num = 1,
  target_filter = function(self, to_select, selected, selected_cards, card, extra_data,user)
    return not Fk:currentRoom():getPlayerById(to_select):hasSkill(self) and #selected == 0
  end,
  can_use = function(self, player, card, extra_data)
    return player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  on_use = function(self, room, cardUseEvent)
    local player = room:getPlayerById(cardUseEvent.from)
    local target = room:getPlayerById(cardUseEvent.tos[1])
    local choice = room:askForChoice(target, { "摸两张牌", "回复一点体力" }, self.name)
    if choice == "摸两张牌" then
      target:drawCards(2, self.name)
    else
      room:recover({
        who = target,
        num = 1,
        recoverBy = player,
        skillName = self.name
      })
    end
    room:addPlayerMark(player, "@@thbattle__cheng_shishen")
    room:addPlayerMark(target, "@@thbattle__cheng_shishen")
  end
}

local thbattle__cheng_shishen_refresh = fk.CreateTriggerSkill {
  name = "#thbattle__cheng_shishen_refresh",
  refresh_events = { fk.TurnStart },
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player:getMark("@@thbattle__cheng_shishen") > 0
  end,
  on_refresh = function(self, event, target, player, data)
    for _, p1 in ipairs(player.room.alive_players) do
      if p1:getMark("@@thbattle__cheng_shishen") > 0 then
        player.room:removePlayerMark(p1, "@@thbattle__cheng_shishen")
      end
    end
  end
}

local thbattle__cheng_shishen_targetmod = fk.CreateTargetModSkill {
  name = "#thbattle__cheng_shishen_targetmod",
  bypass_distances = function(self, player, skill, card, to)
    local players = {}
    for _, p in ipairs(Fk:currentRoom().alive_players) do
      if p:getMark("@@thbattle__cheng_shishen") > 0 then
        table.insertIfNeed(players, p)
      end
    end
    if #players > 1 then
      for _, p1 in ipairs(players) do
        if p1:inMyAttackRange(to) then
          return card.trueName == "slash" and p1.phase == Player.Play
        end
      end
    end
  end
}

thbattle__cheng_shishen:addRelatedSkill(thbattle__cheng_shishen_targetmod)
thbattle__cheng_shishen:addRelatedSkill(thbattle__cheng_shishen_refresh)
thbattle__cheng:addSkill(thbattle__cheng_feixiang)
thbattle__cheng:addSkill(thbattle__cheng_shishen)
Fk:loadTranslationTable {
  ["thbattle__cheng"] = "橙",
  ["#thbattle__cheng"] = "凶兆的黑喵",
  ["~thbattle__cheng"] = "蓝大人~他们好可怕~😭~o(╥﹏╥)o",
  ["designer:thbattle__cheng"] = "Rem",
  ["cv:thbattle__cheng"] = "shourei小N",
  ["illustrator:thbattle__cheng"] = "和茶",


  ["thbattle__cheng_feixiang"] = "飞翔韦驮天",
  ["$thbattle__cheng_feixiang"] = "喵呜~~(>^ω^<)🐱",
  [":thbattle__cheng_feixiang"] = "出牌阶段限一次，你使用【弹幕】或【单体符卡】时，可以额外指定一个目标。" .. "<br/><font color='red'>>></font> 此处不能使用【人形操控】",
  ["#thbattle__cheng_feixiang-choose"] = "飞翔韦驮天：你可以额外选择一名目标",

  ["thbattle__cheng_shishen"] = "式神",
  ["$thbattle__cheng_shishen"] = "喵~喵~喵~~(>^ω^<)🐱",
  [":thbattle__cheng_shishen"] = "限定技，出牌阶段，你可以令一名其他角色选择一项：<font color='red'>>></font> 摸两张牌，<font color='red'>>></font> 回复1点体力。" ..
      "直到下次你的回合开始时，你与其可以在出牌阶段对对方攻击范围内的角色使用【弹幕】。",
  ["@@thbattle__cheng_shishen"] = "式神",

}



-- 跟青蛙过不去的笨蛋 琪露诺 体力：4

-- 最强：出牌阶段限一次，你可以指定一名攻击范围内有你的角色，该角色选择一项：
-- >> 对你使用一张弹幕。
-- >> 令你弃置其一张牌。

-- 完美冻结：每当你使用弹幕或弹幕战对其他角色造成伤害时，你可以防止此次伤害，并令该角色弃置一张牌，若其弃置的不为装备区的牌，其失去1点体力。

-- （画师：渚FUN，CV：君寻

local thbattle__qilunuo = General:new(extension, "thbattle__qilunuo", "tho", 4, 4, 2)

local thbattle__qilunuo_zuiqiang = fk.CreateActiveSkill {
  name = "thbattle__qilunuo_zuiqiang",
  anim_type = "control",
  prompt = "#thbattle__qilunuo_zuiqiang",
  target_filter = function(self, to_select, selected, selected_cards, card, extra_data,user)
    local target = Fk:currentRoom():getPlayerById(to_select)
    return target:inMyAttackRange(user) and #selected == 0 and not target:isNude()
  end,
  target_num = 1,
  max_phase_use_time = 1,
  on_use = function(self, room, cardUseEvent)
    local target = room:getPlayerById(cardUseEvent.tos[1])
    local player = room:getPlayerById(cardUseEvent.from)
    local use = room:askForUseCard(target, self.name, "slash",
      "#thbattle__qilunuo_zuiqiang-use:" .. player.id, true, { exclusive_targets = { player.id } })
    if use then
      room:useCard(use)
    else
      if not target:isNude() then
        local card = room:askForCardChosen(player, target, "he", self.name)
        room:throwCard(card, self.name, target, player)
      end
    end
  end
}

local thbattle__qilunuo_wanmeidongjie = fk.CreateTriggerSkill {
  name = "thbattle__qilunuo_wanmeidongjie",
  prompt = "#thbattle__qilunuo_wanmeidongjie",
  anim_type = "offensive",
  events = { fk.DamageCaused },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.from == player and data.card and
        (data.card.trueName == "slash" or data.card.trueName == "duel")
  end,
  on_use = function(self, event, target, player, data)
    local targetPlayer = data.to
    local room = player.room
    if targetPlayer:isNude() then
      return true
    end
    local discard, hand_cids
    hand_cids = targetPlayer:getCardIds("h")
    discard = room:askForDiscard(targetPlayer, 1, 1, false, self.name, true, ".|.|.|equip,hand",
      "#thbattle__qilunuo_wanmeidongjie-discard")[1]
    if discard and #hand_cids > 0 and table.contains(hand_cids, discard) then
      room:loseHp(targetPlayer, 1, self.name)
    end
    return true
  end
}

thbattle__qilunuo:addSkill(thbattle__qilunuo_zuiqiang)
thbattle__qilunuo:addSkill(thbattle__qilunuo_wanmeidongjie)

Fk:loadTranslationTable {
  ["thbattle__qilunuo"] = "琪露诺",
  ["#thbattle__qilunuo"] = "跟青蛙过不去的笨蛋",
  ["~thbattle__qilunuo"] = "baka,baka,baka~o(╥﹏╥)o",
  ["designer:thbattle__qilunuo"] = "Rem",
  ["cv:thbattle__qilunuo"] = "君寻",
  ["illustrator:thbattle__qilunuo"] = "渚FUN",


  ["thbattle__qilunuo_zuiqiang"] = "最强",
  ["$thbattle__qilunuo_zuiqiang"] = "老娘最强！😆",
  [":thbattle__qilunuo_zuiqiang"] = "出牌阶段限一次，你可以指定一名攻击范围内有你的角色，该角色选择一项：<br/>" ..
      "<font color='red'>>></font> 对你使用一张弹幕。<br/>" ..
      "<font color='red'>>></font> 令你弃置其一张牌。",
  ["#thbattle__qilunuo_zuiqiang"] = "最强：你可以指定一名攻击范围内有你的角色，令其对你使用一张弹幕，否则你弃置其一张牌",
  ["#thbattle__qilunuo_zuiqiang-use"] = "最强：你可以对【%src】使用一张【杀】，否则其弃置你一张牌。",

  ["thbattle__qilunuo_wanmeidongjie"] = "完美冻结",
  ["$thbattle__qilunuo_wanmeidongjie"] = "零下⑨度！🍧",
  [":thbattle__qilunuo_wanmeidongjie"] = "每当你使用【弹幕】或【弹幕战】对其他角色造成伤害时，你可以防止此次伤害，并令该角色弃置一张牌，若其弃置的不为装备区的牌，其失去1点体力。",
  ["#thbattle__qilunuo_wanmeidongjie"] = "完美冻结：你可以防止此次伤害，并令该角色弃置一张牌，若其弃置的不为装备区的牌，其失去1点体力。",
  ["#thbattle__qilunuo_wanmeidongjie-discard"] = "完美冻结：请弃置一张牌,若为手牌区的牌，则你失去1点体力",

}


-- 全身萌点的保姆 大妖精 体力：3

-- 支援：出牌阶段，你可将任意张牌交给其他角色，此阶段你给出的牌首次达到三张时，你回复1点体力。

-- 卖萌：锁定技，摸牌阶段你额外摸X张牌（X为你已损失的体力值）。

-- （画师：渚FUN，CV：简翎）



local thbattle__dayaojing = General:new(extension, "thbattle__dayaojing", "tho", 3, 3, 2)

local thbattle__dayaojing_zhiyuan = fk.CreateActiveSkill {
  name = "thbattle__dayaojing_zhiyuan",
  prompt = "#thbattle__dayaojing_zhiyuan",
  anim_type = "support",
  card_filter = Util.TrueFunc,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, player)
    return #selected == 0 and to_select ~= player.id
  end,
  target_num = 1,
  min_card_num = 1,
  on_use = function(self, room, effect)
    local target = room:getPlayerById(effect.tos[1])
    local player = room:getPlayerById(effect.from)
    local cards = effect.cards
    local marks = player:getMark("thbattle__dayaojing_zhiyuan-phase")
    room:moveCardTo(cards, Player.Hand, target, fk.ReasonGive, self.name, nil, false, player.id)
    room:addPlayerMark(player, "thbattle__dayaojing_zhiyuan-phase", #cards)
    if marks < 3 and marks + #cards >= 3 and not player.dead and player:isWounded() then
      room:recover {
        who = player,
        num = 1,
        recoverBy = player,
        skillName = self.name
      }
    end
  end,
}


local thbattle__dayaojing_maimeng = fk.CreateTriggerSkill {
  name = "thbattle__dayaojing_maimeng",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = { fk.DrawNCards },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player:isWounded()
  end,
  on_use = function(self, event, target, player, data)
    data.n = data.n + player.maxHp - player.hp
  end
}

thbattle__dayaojing:addSkill(thbattle__dayaojing_zhiyuan)
thbattle__dayaojing:addSkill(thbattle__dayaojing_maimeng)

Fk:loadTranslationTable {
  ["thbattle__dayaojing"] = "大妖精",
  ["#thbattle__dayaojing"] = "全身萌点的保姆",
  ["~thbattle__dayaojing"] = "对，对不起...没有帮上..什么忙——————😖",
  ["designer:thbattle__dayaojing"] = "Rem",
  ["cv:thbattle__dayaojing"] = "简翎",
  ["illustrator:thbattle__dayaojing"] = "渚FUN",


  ["thbattle__dayaojing_zhiyuan"] = "支援",
  ["$thbattle__dayaojing_zhiyuan"] = "请..请务必收下！😊",
  [":thbattle__dayaojing_zhiyuan"] = "出牌阶段，你可将任意张牌交给其他角色，此阶段你给出的牌首次达到三张时，你回复1点体力。",
  ["#thbattle__dayaojing_zhiyuan"] = "支援：你可将任意张牌交给其他角色，此阶段你给出的牌首次达到三张时，你回复1点体力。",

  ["thbattle__dayaojing_maimeng"] = "卖萌",
  ["$thbattle__dayaojing_maimeng"] = "欸嘿嘿...😊",
  [":thbattle__dayaojing_maimeng"] = "锁定技，摸牌阶段你额外摸X张牌（X为你已损失的体力值）。",

}

-- 伪月主谋 八意永琳 体力：3

-- 天丝：出牌阶段限一次，你可以弃置一名角色的一张牌，并令其选择一项：
-- >> 回复1点体力。
-- >> 展示牌堆底的3张牌，获得其中的非基本牌，并弃置其他的牌。

-- 月弦：你可以将一张手牌置于牌堆顶或牌堆底底，视为使用或打出了一张弹幕。

-- （画师：渚FUN，CV：VV）

local thbattle__bayiyonglin = General:new(extension, "thbattle__bayiyonglin", "tho", 3, 3, 2)

local thbattle__bayiyonglin_tiansi = fk.CreateActiveSkill {
  name = "thbattle__bayiyonglin_tiansi",
  prompt = "#thbattle__bayiyonglin_tiansi",
  anim_type = "support",
  target_filter = function(self, to_select, selected)
    return #selected == 0 and not Fk:currentRoom():getPlayerById(to_select):isNude()
  end,
  target_num = 1,
  max_phase_use_time = 1,
  on_use = function(self, room, effect)
    local target = room:getPlayerById(effect.tos[1])
    local player = room:getPlayerById(effect.from)

    local discard = room:askForCardChosen(player, target, "he", self.name)
    room:throwCard(discard, self.name, target, player)
    local choice
    local choices = { "回复1点体力", "展示牌堆底3张牌，获得牌堆底的非基本牌" }
    if target:isWounded() then
      choice = room:askForChoice(target, choices, self.name, "#thbattle__bayiyonglin_tiansi-choice")
    else
      choice = choices[2]
    end
    if choice == choices[1] then
      room:recover({
        who = target,
        num = 1,
        recoverBy = player,
        skillName = self.name,
      })
    else
      local getcards = room:getNCards(3, "bottom")
      room:moveCards({
        ids = getcards,
        toArea = Card.Processing,
        moveReason = fk.ReasonJustMove,
        skillName = self.name,
        proposer = player.id
      })
      for _, cid in ipairs(getcards) do
        if Fk:getCardById(cid).type ~= Card.TypeBasic then
          room:obtainCard(target, cid, true, fk.ReasonPrey, player.id, self.name)
          table.removeOne(getcards, cid)
        end
      end
      room:moveCards({
        ids = getcards,
        toArea = Card.DiscardPile,
        moveReason = fk.ReasonDiscard,
      })
    end
  end,
}


local thbattle__bayiyonglin_yuexian = fk.CreateViewAsSkill {
  name = "thbattle__bayiyonglin_yuexian",
  prompt = "#thbattle__bayiyonglin_yuexian",
  pattern = "danmu__slash",
  anim_type = "offensive",
  view_as = function(self, cards,user)
    local c = Fk:cloneCard("danmu__slash")
    c.skillName = self.name
    return c
  end,
  before_use = function(self, player, use)
    local room = player.room
    if #player:getCardIds("h") > 0 then
      local targetCard = room:askForCard(player, 1, 1, false, self.name, false, ".|.|.|hand",
        "#thbattle__bayiyonglin_yuexian-choose_card")
      if #targetCard > 0 then
        local choice = room:askForChoice(player, { "Top", "Bottom" }, self.name,
          "#thbattle__bayiyonglin_yuexian-choice")
        if choice == "Top" then
          room:moveCards({
            ids = targetCard,
            from = player.id,
            toArea = Card.DrawPile,
            moveReason = fk.ReasonPut,
            proposer = player.id,
            moveVisible = true,
          })
        else
          room:moveCards({
            ids = targetCard,
            from = player.id,
            toArea = Card.DrawPile,
            moveReason = fk.ReasonPut,
            proposer = player.id,
            moveVisible = true,
            drawPilePosition = -1,
          })
        end
      end
    end
  end,
  enabled_at_play = function(self, player)
    return self:withinTimesLimit(player, Player.HistoryPhase)
  end,
}


thbattle__bayiyonglin:addSkill(thbattle__bayiyonglin_tiansi)
thbattle__bayiyonglin:addSkill(thbattle__bayiyonglin_yuexian)

Fk:loadTranslationTable {
  ["thbattle__bayiyonglin"] = "八意永琳",
  ["#thbattle__bayiyonglin"] = "伪月主谋",
  ["~thbattle__bayiyonglin"] = "就不吃药，就要萌萌哒~😙",
  ["designer:thbattle__bayiyonglin"] = "Rem",
  ["cv:thbattle__bayiyonglin"] = "VV",
  ["illustrator:thbattle__bayiyonglin"] = "渚FUN",


  ["thbattle__bayiyonglin_tiansi"] = "天丝",
  ["$thbattle__bayiyonglin_tiansi"] = "emmmm药不能停💊",
  [":thbattle__bayiyonglin_tiansi"] = "出牌阶段限一次，你可以弃置一名角色的一张牌，并令其选择一项：<br/>" ..
      "<font color='red'>>></font> 回复1点体力。<br/>" ..
      "<font color='red'>>></font> 展示牌堆底的3张牌，获得其中的非基本牌，并弃置其他的牌。",
  ["#thbattle__bayiyonglin_tiansi"] = "天丝：你可以弃置一名角色的一张牌,令一名角色选择回复1点体力，或者展示牌堆底3张牌，其获得其中非基本牌",
  ["#thbattle__bayiyonglin_tiansi-choice"] = "天丝：请选择一项",

  ["thbattle__bayiyonglin_yuexian"] = "月弦",
  ["$thbattle__bayiyonglin_yuexian"] = "请不要放弃治疗💉",
  [":thbattle__bayiyonglin_yuexian"] = "你可以将一张手牌置于牌堆顶或牌堆底，视为使用或打出了一张【弹幕】。",
  ["#thbattle__bayiyonglin_yuexian"] = "月弦：你可以将一张手牌置于牌堆顶或牌堆底，视为使用或打出了一张【弹幕】。",
  ["#thbattle__bayiyonglin_yuexian-choose_card"] = "月弦：请选择一张手牌",
  ["#thbattle__bayiyonglin_yuexian-choice"] = "月弦：请选择将此牌置于牌堆顶或牌堆底",

}

-- 恶魔之妹 芙兰朵露 体力：4

-- 狂咲：摸牌阶段，你可以少摸一张牌，若如此做，你获得以下效果直到回合结束：
-- >> 当你没有干劲时，你可以对本阶段内没有成为过弹幕目标的其他角色使用弹幕。
-- >> 你为伤害来源的弹幕和弹幕战造成的伤害+1。

-- 毁灭：锁定技，每当你使用弹幕或弹幕战指定其他角色为目标后，其所有技能无效直到回合结束。

-- （画师：月见，CV：shourei小N）

local thbattle__fulanduolu = General:new(extension, "thbattle__fulanduolu", "tho", 4, 4, 2)

local thbattle__fulanduolu_kuangxiao = fk.CreateTriggerSkill {
  name = "thbattle__fulanduolu_kuangxiao",
  prompt = "#thbattle__fulanduolu_kuangxiao",
  anim_type = "offensive",
  events = { fk.DrawNCards },
  on_use = function(self, event, target, player, data)
    data.n = data.n - 1
    if data.n < 0 then data.n = 0 end
    THB_Utility.setStatusMark(player, "@@thbattle__fulanduolu_kuangxiao-turn")
  end
}

local thbattle__fulanduolu_kuangxiao_danmu_target = fk.CreateTriggerSkill {
  name = "#thbattle__fulanduolu_kuangxiao_danmu_target",
  refresh_events = { fk.TargetSpecified },
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card and data.card.trueName == "slash" and
        player:getMark("@@thbattle__fulanduolu_kuangxiao-turn") > 0
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    local targetplayer = room:getPlayerById(data.to)
    room:addPlayerMark(targetplayer, "thbattle__fulanduolu_kuangxiao_target-phase")
  end,
}

local thbattle__fulanduolu_kuangxiao_danmu = fk.CreateTargetModSkill {
  name = "#thbattle__fulanduolu_kuangxiao_danmu",
  bypass_times = function(self, player, skill, scope, card, to)
    return player:getMark("@@thbattle__fulanduolu_kuangxiao-turn") > 0 and card and card.trueName == "slash"
        and to:getMark("thbattle__fulanduolu_kuangxiao_target-phase") == 0 and scope == Player.HistoryPhase
        and player:hasSkill(thbattle__fulanduolu_kuangxiao)
  end,
}
local thbattle__fulanduolu_kuangxiao_damage = fk.CreateTriggerSkill {
  name = "#thbattle__fulanduolu_kuangxiao_damage",
  frequency = Skill.Compulsory,
  events = { fk.DamageCaused },
  main_skill = thbattle__fulanduolu_kuangxiao,
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(thbattle__fulanduolu_kuangxiao) and
        player:getMark("@@thbattle__fulanduolu_kuangxiao-turn") > 0
        and data.card and (data.card.trueName == "slash" or data.card.trueName == "duel")
  end,
  on_use = function(self, event, target, player, data)
    data.damage = (data.damage or 0) + 1
  end
}


local thbattle__fulanduolu_huimie = fk.CreateTriggerSkill {
  name = "thbattle__fulanduolu_huimie",
  anim_type = "offensive",
  frequency = Skill.Compulsory,
  events = { fk.TargetSpecified },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card and
        (data.card.trueName == "slash" or data.card.trueName == "duel")
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targetplayer = room:getPlayerById(data.to)
    THB_Utility.setStatusMark(targetplayer, "@@thbattle__fulanduolu_huimie-turn")
  end,
}

local thbattle__fulanduolu_huimie_invalidity = fk.CreateInvaliditySkill {
  name = "#thbattle__fulanduolu_huimie_invalidity",
  invalidity_func = function(self, from, skill)
    return from:getMark("@@thbattle__fulanduolu_huimie-turn") > 0
  end,
}


thbattle__fulanduolu_kuangxiao:addRelatedSkill(thbattle__fulanduolu_kuangxiao_danmu)
thbattle__fulanduolu_kuangxiao:addRelatedSkill(thbattle__fulanduolu_kuangxiao_damage)
thbattle__fulanduolu_kuangxiao:addRelatedSkill(thbattle__fulanduolu_kuangxiao_danmu_target)
thbattle__fulanduolu_huimie:addRelatedSkill(thbattle__fulanduolu_huimie_invalidity)
thbattle__fulanduolu:addSkill(thbattle__fulanduolu_kuangxiao)
thbattle__fulanduolu:addSkill(thbattle__fulanduolu_huimie)

Fk:loadTranslationTable {
  ["thbattle__fulanduolu"] = "芙兰朵露",
  ["#thbattle__fulanduolu"] = "恶魔之妹",
  ["~thbattle__fulanduolu"] = "姐姐大人...为什么🥺🥺",
  ["designer:thbattle__fulanduolu"] = "Rem",
  ["cv:thbattle__fulanduolu"] = "shourei小N",
  ["illustrator:thbattle__fulanduolu"] = "月见",


  ["thbattle__fulanduolu_kuangxiao"] = "狂咲",
  ["$thbattle__fulanduolu_kuangxiao"] = "玩坏你哟~~🥰🥰",
  [":thbattle__fulanduolu_kuangxiao"] = "摸牌阶段，你可以少摸一张牌，若如此做，你获得以下效果直到回合结束：" ..
      "<font color='red'>>></font> 当你没有干劲时（没有【弹幕】使用次数时），你可以对本阶段内没有成为过【弹幕】目标的其他角色使用【弹幕】。" ..
      "<font color='red'>>></font> 你为伤害来源的【弹幕】和【弹幕战】造成的伤害+1。",
  ["#thbattle__fulanduolu_kuangxiao"] = "狂咲：你可以少摸一张牌，获得以下效果：你可以对本阶段内没有成为过【弹幕】目标的其他角色使用【弹幕】；你为伤害来源的【弹幕】和【弹幕】造成的伤害+1。",
  ["@@thbattle__fulanduolu_kuangxiao-turn"] = "狂咲",
  ["@!thbattle__fulanduolu_kuangxiao-turn"] = "狂咲",
  ["#thbattle__fulanduolu_kuangxiao_damage"] = "狂咲",
  ["#thbattle__fulanduolu_kuangxiao_danmu_target"] = "狂咲",

  ["thbattle__fulanduolu_huimie"] = "毁灭",
  [":thbattle__fulanduolu_huimie"] = "锁定技，每当你使用弹幕或弹幕战指定其他角色为目标后，其所有技能无效直到回合结束。",
  ["@@thbattle__fulanduolu_huimie-turn"] = "毁灭",
  ["@!thbattle__fulanduolu_huimie-turn"] = "毁灭",

}



-- 永远的公主殿下 蓬莱山辉夜 体力：3

-- 难题：每当一名角色令你回复1点体力后，你可以令其摸一张牌；每当你受到一次伤害后，你可以令伤害来源选择一项：>> 交给你一张方块牌，>> 失去1点体力。

-- 永夜：你的回合外，每当其他角色使用的红色基本牌置入弃牌堆时，你可以将一张红色基本牌或装备牌当封魔阵对其使用。

-- （画师：噗呼噗呼@星の妄想乡，CV：shourei小N）

local thbattle__huiye = General:new(extension, "thbattle__huiye", "tho", 3, 3, 2)

local thbattle__huiye_nanti = fk.CreateTriggerSkill {
  name = "thbattle__huiye_nanti",
  anim_type = "special",
  events = { fk.HpRecover, fk.Damaged },
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(self) then
      if event == fk.HpRecover then
        return data.recoverBy
      else
        return data.from
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if event == fk.HpRecover then
      return room:askForSkillInvoke(player, self.name, nil,
        "#thbattle__huiye_nanti-HpRecover:" .. data.recoverBy.id .. "::" .. data.num)
    else
      return room:askForSkillInvoke(player, self.name, nil, "#thbattle__huiye_nanti-Damaged:" .. data.from.id)
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.HpRecover then
      data.recoverBy:drawCards(data.num, self.name)
    else
      local choice_card = room:askForCard(data.from, 1, 1, true, self.name, true, ".|.|diamond",
        "#thbattle__huiye_nanti-choose_card:" .. player.id)
      if #choice_card > 0 then
        room:obtainCard(player, choice_card, true, fk.ReasonGive, player.id, self.name)
      else
        room:loseHp(data.from, 1, self.name)
      end
    end
  end
}

local thbattle__huiye_yongye = fk.CreateTriggerSkill {
  name = "thbattle__huiye_yongye",
  anim_type = "control",
  events = { fk.AfterCardsMove },
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) or player:isNude() or player.phase ~= Player.NotActive then return false end
    if #table.filter(player:getCardIds("he"), function(cid)
          local card = Fk:getCardById(cid)
          return card.color == Card.Red and (card.type == Card.TypeBasic or card.type == Card.TypeEquip)
        end) == 0 then
      return false
    end
    local room = player.room
    local move_event = room.logic:getCurrentEvent()
    local parent_event = move_event.parent
    local card_ids = {}
    if parent_event ~= nil then
      if parent_event.event == GameEvent.UseCard then
        local parent_data = parent_event.data[1]
        if parent_data.from ~= player.id then
          self.cost_data = parent_data.from
          card_ids = room:getSubcardsByRule(parent_data.card)
        end
      end
    end
    for _, move in ipairs(data) do
      if move.toArea == Card.DiscardPile then
        if #card_ids > 0 then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.Processing and table.contains(card_ids, info.cardId) and
                Fk:getCardById(info.cardId).color == Card.Red and Fk:getCardById(info.cardId).type == Card.TypeBasic then
              p(#player.room:getPlayerById(self.cost_data):getCardIds("j"))
              p(table.find(player.room:getPlayerById(self.cost_data):getCardIds("j"), function(cid)
                return Fk:getCardById(cid).name == "fengmozhen__indulgence"
              end))
              if self.cost_data and #player.room:getPlayerById(self.cost_data):getCardIds("j") > 0 and
                  table.find(player.room:getPlayerById(self.cost_data):getCardIds("j"), function(cid)
                    p(Fk:getCardById(cid).skillName)
                    return Fk:getCardById(cid).name == "fengmozhen__indulgence" or
                        Fk:getCardById(cid).skillName == self.name
                  end) then
                return false
              else
                return true
              end
            end
          end
        end
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if not room:askForSkillInvoke(player, self.name) then
      return false
    end
    local RedBasic_cids = room:askForCard(player, 1, 1, true, self.name, true,
      ".|.|heart,diamond|hand,equip|.|^trick",
      "#thbattle__huiye_yongye-choose_card:" .. self.cost_data)
    if #RedBasic_cids > 0 then
      local target_id = self.cost_data
      self.cost_data = { RedBasic_cids, target_id }
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = self.cost_data[1][1]
    local to = room:getPlayerById(self.cost_data[2])
    local use = U.askForUseVirtualCard(room, player, "fengmozhen__indulgence", self.cost_data[1], self.name)
    local card = Fk:cloneCard("fengmozhen__indulgence")
    card:addSubcard(cards)
    card.skillName = self.name
    if player:isProhibited(to, card) then return end
    use.from = player.id
    use.tos = table.map({ to }, function(p) return { p.id } end)
    use.card = card
    if not use then return end
    room:useCard(use)
  end,
}


thbattle__huiye:addSkill(thbattle__huiye_nanti)
thbattle__huiye:addSkill(thbattle__huiye_yongye)

Fk:loadTranslationTable {
  ["thbattle__huiye"] = "蓬莱山辉夜",
  ["#thbattle__huiye"] = "永远的公主殿下",
  ["~thbattle__huiye"] = "这游戏连存档都没有怎么玩!😡",
  ["designer:thbattle__huiye"] = "Rem",
  ["cv:thbattle__huiye"] = "shourei小N",
  ["illustrator:thbattle__huiye"] = "噗呼噗呼@星の妄想乡",


  ["thbattle__huiye_nanti"] = "难题",
  ["$thbattle__huiye_nanti1"] = "这一题，是没有答案的😎",
  ["$thbattle__huiye_nanti2"] = "豆腐脑是甜的，还是咸的？🤔",
  [":thbattle__huiye_nanti"] = "每当一名角色令你回复1点体力后，你可以令其摸一张牌；每当你受到一次伤害后，你可以令伤害来源选择一项：" ..
      "<font color='red'>>></font> 交给你一张方块牌，<font color='red'>>></font> 失去1点体力。",
  ["#thbattle__huiye_nanti-HpRecover"] = "难题：你可以令%src摸%arg张牌",
  ["#thbattle__huiye_nanti-Damaged"] = "难题：你可以令%src交给你一张♦方片牌，否则其失去1点体力",
  ["#thbattle__huiye_nanti-choose_card"] = "难题：请交给%src一张♦方片牌，否则你失去1点体力",

  ["thbattle__huiye_yongye"] = "永夜",
  ["$thbattle__huiye_yongye"] = "陷入永夜吧！🌙",
  [":thbattle__huiye_yongye"] = "你的回合外，每当其他角色使用的红色基本牌置入弃牌堆时，你可以将一张红色基本牌或装备牌当【封魔阵】对其使用。",
  ["#thbattle__huiye_yongye-choose_card"] = "永夜:你可以将一张红色基本牌或装备牌当【封魔阵】对%src使用。",

}


-- 图书管理员 小恶魔 体力：4

-- 寻找：出牌阶段限一次，你可以弃置至多X张牌，然后摸等量的牌。（X为场上存活角色数）

-- （画师：渚FUN/Takibi，CV：VV）

local thbattle__xiaoemo = General:new(extension, "thbattle__xiaoemo", "tho", 4, 4, 2)

local thbattle__xiaoemo_xunzhao = fk.CreateActiveSkill {
  name = "thbattle__xiaoemo_xunzhao",
  prompt = function(self, selected_cards, selected_targets)
    return "#thbattle__xiaoemo_xunzhao-active:::" .. #Fk:currentRoom().alive_players
  end,
  anim_type = "drawcard",
  max_phase_use_time = 1,
  min_card_num = 1,
  max_card_num = function()
    return #Fk:currentRoom().alive_players
  end,
  card_filter =function (self, to_select, selected, user)
    return not user:prohibitDiscard(Fk:getCardById(to_select)) and #selected < #Fk:currentRoom().alive_players
  end,
  on_use = function(self, room, effect)
    local from = room:getPlayerById(effect.from)
    room:throwCard(effect.cards, self.name, from, from)
    if from:isAlive() then
      from:drawCards(#effect.cards, self.name)
    end
  end,
}


thbattle__xiaoemo:addSkill(thbattle__xiaoemo_xunzhao)

Fk:loadTranslationTable {
  ["thbattle__xiaoemo"] = "小恶魔",
  ["#thbattle__xiaoemo"] = "图书管理员",
  ["~thbattle__xiaoemo"] = "这边没有。。去那边找找好了————",
  ["designer:thbattle__xiaoemo"] = "Rem",
  ["cv:thbattle__xiaoemo"] = "VV",
  ["illustrator:thbattle__xiaoemo"] = "渚FUN/Takibi",


  ["thbattle__xiaoemo_xunzhao"] = "寻找",
  ["$thbattle__xiaoemo_xunzhao"] = "诶？！本子都被姆Q扔掉了吗？😣",
  [":thbattle__xiaoemo_xunzhao"] = "出牌阶段限一次，你可以弃置至多X张牌，然后摸等量的牌。（X为场上存活角色数）",
  ["#thbattle__xiaoemo_xunzhao-active"] = "寻找：你可以弃置至多%arg张牌，然后摸等量的牌",

}

-- 愉快的遗忘之伞 多多良小伞 体力：3

-- 惊吓：出牌阶段限一次，你可以选择一张手牌并指定一名其他角色，该角色选择一种花色后，获得此牌并明置之。若此牌与其选择的花色不同，你对其造成1点伤害。

-- 愉快：锁定技，摸牌阶段摸牌后，你令一名角色摸一张牌。

-- （画师：霏茶，CV：VV）

local thbattle__xiaosan = General:new(extension, "thbattle__xiaosan", "tho", 3, 3, 2)

local thbattle__xiaosan_jingxia = fk.CreateActiveSkill {
  name = "thbattle__xiaosan_jingxia",
  prompt = "#thbattle__xiaosan_jingxia-active",
  anim_type = "offensive",
  max_phase_use_time = 1,
  card_num = 1,
  card_filter =function (self, to_select, selected, user)
    return #selected < 1 and table.contains(user:getCardIds("h"), to_select) and
        Fk:getCardById(to_select).suit ~= Card.NoSuit
  end,
  target_filter = function(self, to_select, selected, selected_cards, card, extra_data,user)
    return #selected == 0 and to_select ~= user.id
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local choice_suit = room:askForChoice(target, { "log_heart", "log_spade", "log_diamond", "log_club" }, self.name,
      "#thbattle__xiaosan_jingxia-choose_suit:" .. player.id)
    room:obtainCard(target, effect.cards, true, fk.ReasonGive, player.id, self.name, "@@thb_mingpai")
    if Fk:getCardById(effect.cards[1]).suit ~= U.ConvertSuit(choice_suit, "sym", "int") then
      room:damage({
        from = player,
        to = target,
        damage = 1,
        skillName = self.name
      })
    end
  end,
}

local thbattle__xiaosan_yukuai = fk.CreateTriggerSkill {
  name = "thbattle__xiaosan_yukuai",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = { fk.EventPhaseEnd },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Draw
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targe_player = room:askForChoosePlayers(player, table.map(room.alive_players, Util.IdMapper), 1, 1,
      "#thbattle__xiaosan_yukuai", self.name, false)
    room:getPlayerById(targe_player[1]):drawCards(1, self.name)
  end
}

thbattle__xiaosan:addSkill(thbattle__xiaosan_jingxia)
thbattle__xiaosan:addSkill(thbattle__xiaosan_yukuai)

Fk:loadTranslationTable {
  ["thbattle__xiaosan"] = "多多良小伞",
  ["#thbattle__xiaosan"] = "愉快的遗忘之伞",
  ["~thbattle__xiaosan"] = "唔————我好恨呐！！",
  ["designer:thbattle__xiaosan"] = "Rem",
  ["cv:thbattle__xiaosan"] = "VV",
  ["illustrator:thbattle__xiaosan"] = "霏茶",


  ["thbattle__xiaosan_jingxia"] = "惊吓",
  ["$thbattle__xiaosan_jingxia"] = "德玛西亚！！😈",
  [":thbattle__xiaosan_jingxia"] = "出牌阶段限一次，你可以选择一张手牌并指定一名其他角色，该角色选择一种花色后，获得此牌并明置之。若此牌与其选择的花色不同，你对其造成1点伤害。",
  ["#thbattle__xiaosan_jingxia-active"] = "惊吓：你可以选择一张手牌并指定一名其他角色，该角色选择一种花色后，获得此牌并明置之。若此牌与其选择的花色不同，你对其造成1点伤害。",
  ["#thbattle__xiaosan_jingxia-choose_suit"] = "惊吓:你将获得%src选择的一张手牌，请选择一种花色，若获得的牌与选择的花色不同，%src对你造成1点伤害。",

  ["thbattle__xiaosan_yukuai"] = "愉快",
  ["$thbattle__xiaosan_yukuai"] = "今天好高兴呀~😊",
  [":thbattle__xiaosan_yukuai"] = "锁定技，摸牌阶段摸牌后，你令一名角色摸一张牌。",
  ["#thbattle__xiaosan_yukuai"] = "愉快：你令一名角色摸一张牌。",

}


-- 乳不巨何以聚人心 小野塚小町 体力：4

-- 彼岸：出牌阶段限一次，你可以弃置一张牌并指定一名其他角色，你与其距离视为1直到回合结束，然后若该角色的体力值为全场最少的（或之一），
--  你选择一项：>> 摸一张牌，>> 弃置其一张牌。

-- 归航：觉醒技，准备阶段开始时，若你体力值小于手牌数且不大于2，你减1点体力上限并获得技能渡钱。
-- >> 渡钱：每当你对距离1的其他角色造成伤害后，你可以获得其一张牌。

-- （画师：渚FUN，CV：VV）

local thbattle__xiaoting = General:new(extension, "thbattle__xiaoting", "tho", 4, 4, 2)

local thbattle__xiaoting_bian = fk.CreateActiveSkill {
  name = "thbattle__xiaoting_bian",
  prompt = "#thbattle__xiaoting_bian-active",
  anim_type = "offensive",
  max_phase_use_time = 1,
  card_num = 1,
  card_filter =function (self, to_select, selected, user)
    return #selected == 0 and Fk:getCardById(to_select) and not user:prohibitDiscard(Fk:getCardById(to_select))
  end,
  target_num = 1,
  target_filter = function(self, to_select, selected, selected_cards, card, extra_data,user)
    return #selected == 0 and to_select ~= user.id
  end,
  can_use = function(self, player, card, extra_data)
    return not player:isNude() and player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    room:throwCard(effect.cards, self.name, player, player)
    THB_Utility.setStatusMark(target, "@@thbattle__xiaoting_bian-turn")
    local target_bool = true
    for _, p in ipairs(room.alive_players) do
      if p.hp < target.hp then
        target_bool = false
      end
    end
    if target_bool then
      local choice
      if target:isNude() then
        choice = "摸一张牌"
      else
        choice = room:askForChoice(player, { "摸一张牌", "弃置其一张牌" })
      end
      if choice == "摸一张牌" then
        player:drawCards(1, self.name)
      else
        local discard = room:askForCardChosen(player, target, "he", self.name, "#thbattle__xiaoting_bian-discard")
        room:throwCard(discard, self.name, target, player)
      end
    end
  end,
}

local thbattle__xiaoting_bian_distance = fk.CreateDistanceSkill {
  name = "#thbattle__xiaoting_bian_distance",
  fixed_func = function(self, from, to)
    if from and to and from.phase ~= Player.NotActive and to:getMark("@@thbattle__xiaoting_bian-turn") > 0 then
      return 1
    end
  end,
}


local thbattle__xiaoting_guihang = fk.CreateTriggerSkill {
  name = "thbattle__xiaoting_guihang",
  anim_type = "big",
  frequency = Skill.Wake,
  events = { fk.EventPhaseStart },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Start and
        player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  can_wake = function(self, event, target, player, data)
    return player.hp < #player:getCardIds("h") and player.hp <= 2
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:changeMaxHp(player, -1)
    room:handleAddLoseSkills(player, "thbattle__xiaoting_duqian")
  end
}

local thbattle__xiaoting_duqian = fk.CreateTriggerSkill {
  name = "thbattle__xiaoting_duqian",
  anim_type = "control",
  prompt = "#thbattle__xiaoting_duqian",
  events = { fk.Damage },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player:distanceTo(data.to) <= 1 and data.to ~= player and
        not data.to:isNude()
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local target_card = room:askForCardChosen(player, data.to, "he", self.name,
      "#thbattle__xiaoting_duqian-choose_card")
    room:obtainCard(player, target_card, false, fk.ReasonPrey, player.id, self.name)
  end
}

thbattle__xiaoting_bian:addRelatedSkill(thbattle__xiaoting_bian_distance)
thbattle__xiaoting:addSkill(thbattle__xiaoting_bian)
thbattle__xiaoting:addSkill(thbattle__xiaoting_guihang)
thbattle__xiaoting:addRelatedSkill(thbattle__xiaoting_duqian)

Fk:loadTranslationTable {
  ["thbattle__xiaoting"] = "小野塚小町",
  ["#thbattle__xiaoting"] = "乳不巨何以聚人心",
  ["~thbattle__xiaoting"] = "啊~~休息，休息一下😪🛏️",
  ["designer:thbattle__xiaoting"] = "Rem",
  ["cv:thbattle__xiaoting"] = "VV",
  ["illustrator:thbattle__xiaoting"] = "渚FUN",


  ["thbattle__xiaoting_bian"] = "彼岸",
  ["$thbattle__xiaoting_bian"] = "三途之川一日游，只要半价~~",
  [":thbattle__xiaoting_bian"] = "出牌阶段限一次，你可以弃置一张牌并指定一名其他角色，你与其距离视为1直到回合结束，" ..
      "然后若该角色的体力值为全场最少的（或之一），你选择一项：<font color='red'>>></font> 摸一张牌，<font color='red'>>></font> 弃置其一张牌。",
  ["#thbattle__xiaoting_bian-active"] = "彼岸：你可以弃置一张牌并指定一名其他角色，你与其距离视为1直到回合结束，然后若该角色的体力值为全场最少的（或之一），你选择一项：>> 摸一张牌，>> 弃置其一张牌。",
  ["@@thbattle__xiaoting_bian-turn"] = "彼岸",
  ["@!thbattle__xiaoting_bian-turn"] = "彼岸",
  ["#thbattle__xiaoting_bian-discard"] = "彼岸：你弃置其一张牌",

  ["thbattle__xiaoting_guihang"] = "归航",
  ["$thbattle__xiaoting_guihang"] = "要开始认真工作了~~",
  [":thbattle__xiaoting_guihang"] = "觉醒技，准备阶段开始时，若你体力值小于手牌数且不大于2，你减1点体力上限并获得技能【<a href=':thbattle__xiaoting_duqian'><font color='red'>渡钱</font></a>】。",

  ["thbattle__xiaoting_duqian"] = "渡钱",
  ["$thbattle__xiaoting_duqian"] = "摆渡费用我就收下了，谢谢惠顾~",
  [":thbattle__xiaoting_duqian"] = "每当你对距离1的其他角色造成伤害后，你可以获得其一张牌。",
  ["#thbattle__xiaoting_duqian"] = "渡钱：你可以获得其一张牌。",
  ["#thbattle__xiaoting_duqian-choose_card"] = "渡钱：你可以获得其一张牌。",


}


-- 绝非普通的强盗少女 雾雨魔理沙 体力：4

-- 借走：出牌阶段限一次，你可以获得其他角色的一张牌，然后该角色可以视为对你使用了一张弹幕。

-- （画师：霏茶，CV：君寻）

local thbattle__molisha = General:new(extension, "thbattle__molisha", "tho", 4, 4, 2)

local thbattle__molisha_jiezou = fk.CreateActiveSkill {
  name = "thbattle__molisha_jiezou",
  prompt = "#thbattle__molisha_jiezou",
  anim_type = "control",
  max_phase_use_time = 1,
  target_num = 1,
  card_filter = Util.FalseFunc,
  target_filter = function(self, to_select, selected, selected_cards, card, extra_data,user)
    return #selected == 0 and to_select ~= user.id and not Fk:currentRoom():getPlayerById(to_select):isNude()
  end,
  can_use = function(self, player, card, extra_data)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local target_card = room:askForCardChosen(player, target, "he", self.name,
      "#thbattle__molisha_jiezou-choose_card:" .. target.id)
    room:obtainCard(player, target_card, false, fk.ReasonPrey, player.id, self.name)
    local choice = room:askForChoice(target,
      { "#thbattle__molisha_jiezou-use_slash:" .. player.id, "#thbattle__molisha_jiezou-dont_use_slash:" ..
      player.id }, self.name)
    if choice == "#thbattle__molisha_jiezou-use_slash:" .. player.id then
      room:useCard({
        from = target.id,
        tos = { { player.id } },
        card = Fk:cloneCard("danmu__slash"),
      })
    end
  end,
}

thbattle__molisha:addSkill(thbattle__molisha_jiezou)

Fk:loadTranslationTable {
  ["thbattle__molisha"] = "雾雨魔理沙",
  ["#thbattle__molisha"] = "绝非普通的强盗少女",
  ["~thbattle__molisha"] = "诶~~都会还给你们的，不要这么凶嘛da⭐ze",
  ["designer:thbattle__molisha"] = "Rem",
  ["cv:thbattle__molisha"] = "君寻",
  ["illustrator:thbattle__molisha"] = "霏茶",


  ["thbattle__molisha_jiezou"] = "借走",
  ["$thbattle__molisha_jiezou"] = "等我死掉以后再还给你好了",
  [":thbattle__molisha_jiezou"] = "出牌阶段限一次，你可以获得其他角色的一张牌，然后该角色可以视为对你使用了一张【弹幕】。",
  ["#thbattle__molisha_jiezou"] = "借走：你可以获得其他角色的一张牌，然后该角色可以视为对你使用了一张【弹幕】。",
  ["#thbattle__molisha_jiezou-choose_card"] = "借走：请选择%src的一张牌获得",
  ["#thbattle__molisha_jiezou-use"] = "借走：你可以视为对%src使用一张【弹幕】",
  ["#thbattle__molisha_jiezou-use_slash"] = "你对%src视为使用一张【弹幕】",
  ["#thbattle__molisha_jiezou-dont_use_slash"] = "你不对%src视为使用一张【弹幕】",


}



-- 我只打盹我不翘班 红美铃 体力：4

-- 龙拳：每当你使用的弹幕被其他角色使用的擦弹抵消时，或其他角色使用的弹幕被你使用的擦弹抵消时，你可以弃置其1张手牌。

-- 背水：觉醒技，准备阶段开始时，若你体力值为全场最低或之一且不大于2时，你减1点体力上限并获得技能太极。
-- >> 太极：你可将弹幕当擦弹，擦弹当弹幕使用或打出。

-- （画师：霏茶，CV：小羽）


local thbattle__hongmeiling = General:new(extension, "thbattle__hongmeiling", "tho", 4, 4, 2)

local thbattle__hongmeiling_longquan = fk.CreateTriggerSkill {
  name = "thbattle__hongmeiling_longquan",
  prompt = "#thbattle__hongmeiling_longquan",
  anim_type = "masochism",
  events = { fk.CardEffectCancelledOut, fk.CardUseFinished },
  can_trigger = function(self, event, target, player, data)
    if not (target == player and player:hasSkill(self)) then return false end
    if event == fk.CardEffectCancelledOut then
      self.cost_data = data.to
      return data.card and data.card.trueName == "slash"
          and not player.room:getPlayerById(data.to):isKongcheng()
    else
      local use = data
      if use.card and use.card.trueName == "jink" and use.toCard and use.toCard.trueName == "slash" then
        local effect = use.responseToEvent
        self.cost_data = effect.from
        return effect.to == player.id and not player.room:getPlayerById(effect.from):isKongcheng()
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local target_player = room:getPlayerById(self.cost_data)
    local target_card = room:askForCardChosen(player, target_player, "h", self.name,
      "#thbattle__hongmeiling_longquan-choose_card")
    room:throwCard(target_card, self.name, target_player, player)
  end
}

local thbattle__hongmeiling_beishui = fk.CreateTriggerSkill {
  name = "thbattle__hongmeiling_beishui",
  anim_type = "big",
  frequency = Skill.Wake,
  events = { fk.EventPhaseStart },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Start and
        player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  can_wake = function(self, event, target, player, data)
    local room = player.room
    return not table.find(room.alive_players, function(p)
      return p.hp < player.hp
    end) and player.hp <= 2
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:changeMaxHp(player, -1)
    room:handleAddLoseSkills(player, "thbattle__hongmeiling_taiji")
  end
}

local thbattle__hongmeiling_taiji = fk.CreateViewAsSkill {
  name = "thbattle__hongmeiling_taiji",
  pattern = "slash,jink",
  card_filter =function (self, to_select, selected, player)
    if #selected == 1 then return false end
    local _c = Fk:getCardById(to_select)
    local c
    if _c.trueName == "slash" then
      c = Fk:cloneCard("cadan__jink")
    elseif _c.trueName == "jink" then
      c = Fk:cloneCard("danmu__slash")
    else
      return false
    end
    return (Fk.currentResponsePattern == nil and player:canUse(c)) or
        (Fk.currentResponsePattern and Exppattern:Parse(Fk.currentResponsePattern):match(c))
  end,
  view_as = function(self, cards,user)
    if #cards ~= 1 then
      return nil
    end
    local _c = Fk:getCardById(cards[1])
    local c
    if _c.trueName == "slash" then
      c = Fk:cloneCard("cadan__jink")
    elseif _c.trueName == "jink" then
      c = Fk:cloneCard("danmu__slash")
    end
    c.skillName = self.name
    c:addSubcard(cards[1])
    return c
  end,
}

local thbattle__hongmeiling_death = fk.CreateTriggerSkill {
  name = "#thbattle__hongmeiling_death",
  frequency = Skill.Compulsory,
  global = true,
  mute = true,
  events = { fk.Death },
  can_trigger = function(self, event, target, player, data)
    return target == player and player.general == "thbattle__hongmeiling"
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local num = math.random(2)
    room:broadcastPlaySound("./packages/thbattle/audio/death/thbattle__hongmeiling" .. math.random(2))
  end,
}

thbattle__hongmeiling:addRelatedSkill(thbattle__hongmeiling_death)
thbattle__hongmeiling:addRelatedSkill(thbattle__hongmeiling_taiji)
thbattle__hongmeiling:addSkill(thbattle__hongmeiling_beishui)
thbattle__hongmeiling:addSkill(thbattle__hongmeiling_longquan)

Fk:loadTranslationTable {
  ["thbattle__hongmeiling"] = "红美铃",
  ["#thbattle__hongmeiling"] = "我只打盹我不翘班",
  ["designer:thbattle__hongmeiling"] = "Rem",
  ["cv:thbattle__hongmeiling"] = "小羽",
  ["illustrator:thbattle__hongmeiling"] = "霏茶",


  ["thbattle__hongmeiling_longquan"] = "龙拳",
  ["$thbattle__hongmeiling_longquan"] = "四两拨千斤！",
  [":thbattle__hongmeiling_longquan"] = "每当你使用的【弹幕】被其他角色使用的【擦弹】抵消时，或其他角色使用的【弹幕】被你使用的【擦弹】抵消时，你可以弃置其1张手牌。",
  ["#thbattle__hongmeiling_longquan"] = "龙拳：你可以弃置其1张手牌。",
  ["#thbattle__hongmeiling_longquan-choose_card"] = "龙拳：你弃置其一张手牌",

  ["thbattle__hongmeiling_beishui"] = "背水",
  ["$thbattle__hongmeiling_beishui"] = "可恶，背水阵！",
  [":thbattle__hongmeiling_beishui"] = "觉醒技，准备阶段开始时，若你体力值为全场最低或之一且不大于2时，你减1点体力上限并获得技能【<a href=':thbattle__hongmeiling_taiji'><font color='red'>太极</font></a>】。",

  ["thbattle__hongmeiling_taiji"] = "太极",
  ["$thbattle__hongmeiling_taiji"] = "呵！",
  [":thbattle__hongmeiling_taiji"] = "你可将【弹幕】当【擦弹】，【擦弹】当【弹幕】使用或打出。",

}

-- 没人气的丰收神 秋穰子 体力：3

-- 丰收：锁定技，摸牌阶段摸牌后，你将手牌数补至五张。

-- 秋祭：出牌阶段限一次，你可以将两张红色牌当五谷丰登使用。

-- 上贡：锁定技，结算五谷丰登时，你首先选择牌，结算完后，你将剩余的牌置于一名角色的明牌区。

-- （画师：和茶，CV：VV）

local thbattle__qiurangzi = General:new(extension, "thbattle__qiurangzi", "tho", 3, 3, 2)

local thbattle__qiurangzi_fengshou = fk.CreateTriggerSkill {
  name = "thbattle__qiurangzi_fengshou",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = { fk.EventPhaseEnd },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Draw and #player:getCardIds("h") < 5
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(5 - #player:getCardIds("h"), self.name)
  end
}

local thbattle__qiurangzi_qiuji = fk.CreateActiveSkill {
  name = "thbattle__qiurangzi_qiuji",
  prompt = "#thbattle__qiurangzi_qiuji",
  anim_type = "drawcard",
  max_phase_use_time = 1,
  card_num = 2,
  card_filter =function (self, to_select, selected, user)
    return #selected < 2 and Fk:getCardById(to_select).color == Card.Red and
        not user:prohibitDiscard(Fk:getCardById(to_select))
  end,
  target_filter = Util.FalseFunc,
  can_use = function(self, player, card, extra_data)
    return not player:isNude() and #player:getCardIds("he") >= 2 and
        player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local cards = Fk:cloneCard("wugufengdeng__amazing_grace")
    cards.skillName = self.name
    cards:addSubcards(effect.cards)
    room:useCard({
      from = player.id,
      tos = table.map(room.alive_players, function(p)
        return { p.id }
      end),
      card = cards,
    })
  end,
}

local thbattle__qiurangzi_shanggong = fk.CreateTriggerSkill {
  name = "thbattle__qiurangzi_shanggong",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = { fk.AfterCardsMove },
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) then
      local e = player.room.logic:getCurrentEvent().parent
      if e and e.event == GameEvent.UseCard then
        local use = e.data[1]
        if use.card.trueName == "amazing_grace" then
          local ids = {}
          for _, move in ipairs(data) do
            if move.toArea == Card.DiscardPile and move.moveReason == fk.ReasonPutIntoDiscardPile then
              for _, info in ipairs(move.moveInfo) do
                if player.room:getCardArea(info.cardId) == Card.DiscardPile then
                  table.insertIfNeed(ids, info.cardId)
                end
              end
            end
          end
          if #ids > 0 then
            self.cost_data = ids
            return true
          end
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = player.room:askForChoosePlayers(player, table.map(player.room:getAlivePlayers(), Util.IdMapper), 1, 1,
      "#thbattle__qiurangzi_shanggong-choose", self.name, false)
    room:obtainCard(room:getPlayerById(to[1]), self.cost_data, true, fk.ReasonJustMove, to[1], self.name,
      "@@thb_mingpai")
  end,
}

local thbattle__qiurangzi_shanggong_trigger = fk.CreateTriggerSkill {
  name = "#thbattle__qiurangzi_shanggong_trigger",
  frequency = Skill.Compulsory,
  events = { fk.BeforeCardUseEffect },
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and data.card and data.card.trueName == "amazing_grace"
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local first, last = {}, {}
    for _, info in ipairs(data.tos) do
      if room:getPlayerById(info[1]):hasSkill(self) then
        table.insert(first, info[1])
      else
        table.insert(last, info[1])
      end
    end
    data.tos = table.map(table.connect(first, last), function(p) return { p } end)
  end,

}

thbattle__qiurangzi_shanggong:addRelatedSkill(thbattle__qiurangzi_shanggong_trigger)
thbattle__qiurangzi:addSkill(thbattle__qiurangzi_fengshou)
thbattle__qiurangzi:addSkill(thbattle__qiurangzi_qiuji)
thbattle__qiurangzi:addSkill(thbattle__qiurangzi_shanggong)

Fk:loadTranslationTable {
  ["thbattle__qiurangzi"] = "秋穰子",
  ["#thbattle__qiurangzi"] = "没人气的丰收神",
  ["~thbattle__qiurangzi"] = "果然没有人气嘛....🥺",
  ["designer:thbattle__qiurangzi"] = "Rem",
  ["cv:thbattle__qiurangzi"] = "VV",
  ["illustrator:thbattle__qiurangzi"] = "和茶",


  ["thbattle__qiurangzi_fengshou"] = "丰收",
  ["$thbattle__qiurangzi_fengshou"] = "诶嘿，大丰收~~🥰",
  [":thbattle__qiurangzi_fengshou"] = "锁定技，摸牌阶段摸牌后，你将手牌数补至五张。",

  ["thbattle__qiurangzi_qiuji"] = "秋祭",
  ["#thbattle__qiurangzi_qiuji"] = "秋祭:你可以将两张红色牌当【五谷丰登】使用。",
  ["$thbattle__qiurangzi_qiuji"] = "麻薯年年有，今年特别多~~🥳",
  [":thbattle__qiurangzi_qiuji"] = "出牌阶段限一次，你可以将两张红色牌当【五谷丰登】使用。",

  ["thbattle__qiurangzi_shanggong"] = "上贡",
  ["#thbattle__qiurangzi_shanggong_trigger"] = "上贡",
  ["$thbattle__qiurangzi_shanggong"] = "浪费粮食，可不是好行为哟~~",
  [":thbattle__qiurangzi_shanggong"] = "锁定技，结算五谷丰登时，你首先选择牌，结算完后，你将剩余的牌置于一名角色的明牌区。",
  ["#thbattle__qiurangzi_shanggong-choose"] = "上贡：你需要将剩余的牌置于一名角色的明牌区。",
}

-- 山中的千里眼 犬走椛 体力：4

-- 缴械：每当你使用弹幕或弹幕战对其他角色造成伤害后，你可以观看其手牌，并将其中任意数量的弹幕或符卡牌暂时移出游戏。该角色被暂时移出的牌会在该角色下一个弃牌阶段后归还回其手牌中。

-- 哨戒：你攻击范围内的一名其它角色的出牌阶段开始时，你可以对其使用一张弹幕。

-- 坚盾：你距离1以内的角色成为其它角色使用的弹幕或单体符卡的目标后，若此卡牌为其出牌阶段时使用的第一张卡牌，取消之并暂时移出游戏。该角色被暂时移出的牌会在该角色下一个弃牌阶段后归还回其手牌中。

-- （画师：和茶，CV：简翎）

local thbattle__quanzouhua = General:new(extension, "thbattle__quanzouhua", "tho", 4, 4, 2)

local thbattle__quanzouhua_jiaoxie = fk.CreateTriggerSkill {
  name = "thbattle__quanzouhua_jiaoxie",
  anim_type = "control",
  events = { fk.Damage },
  prompt = "#thbattle__quanzouhua_jiaoxie",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card and
        (data.card.trueName == "slash" or data.card.trueName == "duel")
        and data.to ~= player and not data.to:isKongcheng()
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    U.viewCards(player, data.to:getCardIds("h"), self.name, "$ViewCardsFrom:" .. data.to.id)
    local cards = table.filter(data.to:getCardIds("h"), function(cid)
      return Fk:getCardById(cid).type == Card.TypeTrick or Fk:getCardById(cid).trueName == "slash"
    end)
    data.to:addToPile("$thbattle_jiaoxie", cards, false, self.name)
  end,

  refresh_events = { fk.EventPhaseEnd },
  can_refresh = function(self, event, target, player, data)
    return target == player and #player:getPile("$thbattle_jiaoxie") > 0 and player.phase ==
        Player.Discard
  end,
  on_refresh = function(self, event, target, player, data)
    local cards = player:getPile("$thbattle_jiaoxie")
    player.room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonJustMove, self.name, nil, false, player.id)
  end,
}

local thbattle__quanzouhua_shaojie = fk.CreateTriggerSkill {
  name = "thbattle__quanzouhua_shaojie",
  anim_type = "offensive",
  events = { fk.EventPhaseStart },
  can_trigger = function(self, event, target, player, data)
    return target ~= player and player:hasSkill(self) and player:inMyAttackRange(target) and
        target.phase == Player.Play and player:canUseTo(Fk:cloneCard("slash"), target)
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#thbattle__quanzouhua_shaojie:" .. target.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local use = room:askForUseCard(player, "slash", nil, "#thbattle__quanzouhua_shaojie-use:" .. target.id, true)
    if use and use.card then
      room:useCard(use)
    end
  end,
}

local thbattle__quanzouhua_jiandun = fk.CreateTriggerSkill {
  name = "thbattle__quanzouhua_jiandun",
  anim_type = "defensive",
  events = { fk.TargetConfirmed },
  can_trigger = function(self, event, target, player, data)
    if target ~= player and player:hasSkill(self) and player:distanceTo(target) <= 1 and data.card and data.from ~= target.id and data.from ~= player.id and
        (data.card.trueName == "slash" or (data.card.type == Card.TypeTrick and data.card.multiple_targets ~= true)) and player.room:getPlayerById(data.from).phase == Player.Play then
      local use_events = player.room.logic:getEventsOfScope(GameEvent.UseCard, 2, function(e)
        local use = e.data[1]
        return use.from == data.from
      end, Player.HistoryPhase)
      return #use_events == 1
    end
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil,
      "#thbattle__quanzouhua_jiandun:" .. target.id .. ":" .. data.from .. ":" .. data.card:toLogString())
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    AimGroup:cancelTarget(data, target.id)
    local use_player = room:getPlayerById(data.from)
    use_player:addToPile("$thbattle_jiaoxie", data.card, false, self.name)
    return true
  end,

  refresh_events = { fk.EventPhaseEnd },
  can_refresh = function(self, event, target, player, data)
    return target == player and #player:getPile("$thbattle_jiaoxie") > 0 and player.phase ==
        Player.Discard
  end,
  on_refresh = function(self, event, target, player, data)
    local cards = player:getPile("$thbattle_jiaoxie")
    player.room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonJustMove, self.name, nil, false, player.id)
  end,
}

thbattle__quanzouhua:addSkill(thbattle__quanzouhua_jiaoxie)
thbattle__quanzouhua:addSkill(thbattle__quanzouhua_shaojie)
thbattle__quanzouhua:addSkill(thbattle__quanzouhua_jiandun)

Fk:loadTranslationTable {
  ["thbattle__quanzouhua"] = "犬走椛",
  ["#thbattle__quanzouhua"] = "山中的千里眼",
  ["~thbattle__quanzouhua"] = "让文文那家伙处理吧..",
  ["designer:thbattle__quanzouhua"] = "Rem",
  ["cv:thbattle__quanzouhua"] = "简翎",
  ["illustrator:thbattle__quanzouhua"] = "和茶",


  ["thbattle__quanzouhua_jiaoxie"] = "缴械",
  ["$thbattle__quanzouhua_jiaoxie1"] = "麻烦过一下安检~",
  ["$thbattle__quanzouhua_jiaoxie2"] = "啊~蓝白条的~~",
  [":thbattle__quanzouhua_jiaoxie"] = "每当你使用【弹幕】或【弹幕战】对其他角色造成伤害后，你可以观看其手牌，" ..
      "并将其中任意数量的【弹幕】或【<a href='thbattle_fuka'><font color='red'>符卡</font></a>】牌暂时移出游戏。该角色被暂时移出的牌会在该角色下一个弃牌阶段后归还回其手牌中。",
  ["$thbattle_jiaoxie"] = "缴械",
  ["#thbattle__quanzouhua_jiaoxie"] = "缴械：你可以观看其手牌，并将其中任意数量的【弹幕】或【符卡】牌暂时移出游戏。该角色被暂时移出的牌会在该角色下一个弃牌阶段后归还回其手牌中。",

  ["thbattle__quanzouhua_shaojie"] = "哨戒",
  ["#thbattle__quanzouhua_shaojie"] = "哨戒:你可以对%src使用一张【弹幕】。",
  ["$thbattle__quanzouhua_shaojie1"] = "大王叫我来巡山~~",
  ["$thbattle__quanzouhua_shaojie2"] = "来者何人~",
  [":thbattle__quanzouhua_shaojie"] = "你攻击范围内的一名其它角色的出牌阶段开始时，你可以对其使用一张【弹幕】。",
  ["#thbattle__quanzouhua_shaojie-use"] = "哨戒:你可以对%src使用一张【弹幕】。",

  ["thbattle__quanzouhua_jiandun"] = "坚盾",
  ["#thbattle__quanzouhua_jiandun"] = "坚盾：你可以令%dest对%src使用的【%arg】无效并将其暂时移出游戏",
  ["$thbattle__quanzouhua_jiandun"] = "我是你们的护盾！",
  [":thbattle__quanzouhua_jiandun"] = "你距离1以内的角色成为其它角色使用的【弹幕】或单体【<a href='thbattle_fuka'><font color='red'>符卡</font></a>】的目标后，" ..
      "若此卡牌为其出牌阶段时使用的第一张卡牌，取消之并暂时移出游戏。该角色被暂时移出的牌会在该角色下一个弃牌阶段后归还回其手牌中。",
}

-- 探宝的小小大将 纳兹琳 体力：3

-- 探宝：准备阶段开始时，你可以进行一次判定，若结果为黑，你获得此牌且你可以重复此流程。

-- 轻敏：你可以将一张黑色手牌当擦弹使用或打出。

-- （画师：月见，CV：小羽）

local thbattle__nazilin = General:new(extension, "thbattle__nazilin", "tho", 3, 3, 2)


local thbattle__nazilin_tanbao = fk.CreateTriggerSkill {
  name = "thbattle__nazilin_tanbao",
  anim_type = "drawcard",
  prompt = "#thbattle__nazilin_tanbao",
  events = { fk.EventPhaseStart },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Start
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    while true do
      local judge = {
        who = player,
        reason = self.name,
        pattern = ".|.|spade,club",
      }
      room:judge(judge)
      if judge.card.color == Card.Black and not player.dead then
        room:obtainCard(player, judge.card, true, fk.ReasonPrey, player.id, self.name)
      end
      if judge.card.color ~= Card.Black or player.dead or not room:askForSkillInvoke(player, self.name) then
        break
      end
    end
  end,
}

local thbattle__nazilin_qingmin = fk.CreateViewAsSkill {
  name = "thbattle__nazilin_qingmin",
  anim_type = "defensive",
  pattern = "jink",
  prompt = "#thbattle__nazilin_qingmin",
  card_filter =function (self, to_select, selected, player)
    if #selected == 1 then return false end
    return Fk:getCardById(to_select).color == Card.Black
        and Fk:currentRoom():getCardArea(to_select) == Player.Hand
  end,
  view_as = function(self, cards,user)
    if #cards ~= 1 then
      return nil
    end
    local c = Fk:cloneCard("cadan__jink")
    c.skillName = self.name
    c:addSubcard(cards[1])
    return c
  end,
}
thbattle__nazilin:addSkill(thbattle__nazilin_tanbao)
thbattle__nazilin:addSkill(thbattle__nazilin_qingmin)

Fk:loadTranslationTable {
  ["thbattle__nazilin"] = "纳兹琳",
  ["#thbattle__nazilin"] = "探宝的小小大将",
  ["~thbattle__nazilin"] = "哎呀，我的宝塔~~",
  ["designer:thbattle__nazilin"] = "Rem",
  ["cv:thbattle__nazilin"] = "小羽",
  ["illustrator:thbattle__nazilin"] = "月见",


  ["thbattle__nazilin_tanbao"] = "探宝",
  ["$thbattle__nazilin_tanbao"] = "biubiubiu~~~",
  [":thbattle__nazilin_tanbao"] = "准备阶段开始时，你可以进行一次判定，若结果为黑，你获得此牌且你可以重复此流程。",
  ["#thbattle__nazilin_tanbao"] = "探宝：你可以进行一次判定，若结果为黑，你获得此牌且你可以重复此流程。",

  ["thbattle__nazilin_qingmin"] = "轻敏",
  ["#thbattle__nazilin_qingmin"] = "轻敏:你可以将一张黑色手牌当【擦弹】使用或打出。",
  ["$thbattle__nazilin_qingmin"] = "略~~诶嘿嘿~~",
  [":thbattle__nazilin_qingmin"] = "你可以将一张黑色手牌当【擦弹】使用或打出。",
}



-- 天河一号的核心 八云蓝 体力：3

-- 神算：准备阶段开始时，你可以观看牌堆顶的X张牌，将其中任意数量的牌以任意顺序置于牌堆顶，其余以任意顺序置于牌堆底。（X为存活角色数且至多为5）

-- 极智：每轮限一次，你的回合外，当非延时符卡效果对一名角色生效后，你可以弃置一张牌，令该符卡效果对那名角色重新进行一次结算，此时使用者视为你。

-- 素裸：锁定技，若你没有手牌，符卡对你造成的伤害-1。

-- （画师：霏茶，CV：shourei小N）

local thbattle__bayunlan = General:new(extension, "thbattle__bayunlan", "tho", 3, 3, 2)

local thbattle__bayunlan_shensuan = fk.CreateTriggerSkill {
  name = "thbattle__bayunlan_shensuan",
  anim_type = "control",
  prompt = function()
    return "#thbattle__bayunlan_shensuan:::" .. math.min(5, #Fk:currentRoom().alive_players)
  end,
  events = { fk.EventPhaseStart },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Start
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:askForGuanxing(player, room:getNCards(math.min(5, #room.alive_players)))
  end
}

local thbattle__bayunlan_jizhi = fk.CreateTriggerSkill {
  name = "thbattle__bayunlan_jizhi",
  anim_type = "control",
  events = { fk.CardEffectFinished },
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and player.phase == Player.NotActive and
        player:usedSkillTimes(self.name, Player.HistoryRound) == 0 and data.card and data.card.type == Card
        .TypeTrick
        and data.card.sub_type ~= Card.SubtypeDelayedTrick and not player:isNude() and
        player:canUseTo(data.card, target)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if room:askForSkillInvoke(player, self.name, nil, "#thbattle__bayunlan_jizhi:" .. target.id .. "::" .. data.card:toLogString()) then
      local target_cids = room:askForDiscard(player, 1, 1, true, self.name, true, ".",
        "#thbattle__bayunlan_jizhi-discard:" .. target.id .. "::" .. data.card:toLogString())
      return #target_cids > 0
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:useCard({
      from = player.id,
      tos = { { target.id } },
      card = data.card,
    })
  end,
}

local thbattle__bayunlan_suluo = fk.CreateTriggerSkill {
  name = "thbattle__bayunlan_suluo",
  frequency = Skill.Compulsory,
  anim_type = "defensive",
  events = { fk.DamageInflicted },
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and data.card and data.card.type == Card.TypeTrick and
        player:isKongcheng()
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    data.damage = (data.damage or 0) - 1
  end,

}

thbattle__bayunlan:addSkill(thbattle__bayunlan_shensuan)
thbattle__bayunlan:addSkill(thbattle__bayunlan_jizhi)
thbattle__bayunlan:addSkill(thbattle__bayunlan_suluo)

Fk:loadTranslationTable {
  ["thbattle__bayunlan"] = "八云蓝",
  ["#thbattle__bayunlan"] = "天河一号的核心",
  ["~thbattle__bayunlan"] = "没有油炸豆腐吗？失算了....",
  ["designer:thbattle__bayunlan"] = "Rem",
  ["cv:thbattle__bayunlan"] = "shourei小N",
  ["illustrator:thbattle__bayunlan"] = "霏茶",


  ["thbattle__bayunlan_shensuan"] = "神算",
  ["$thbattle__bayunlan_shensuan"] = "掐指一算，这次能摸到，油炸豆腐的说~~",
  [":thbattle__bayunlan_shensuan"] = "准备阶段开始时，你可以观看牌堆顶的X张牌，将其中任意数量的牌以任意顺序置于牌堆顶，其余以任意顺序置于牌堆底。（X为存活角色数且至多为5）",
  ["#thbattle__bayunlan_shensuan"] = "神算:你可以观看牌堆顶的%arg张牌，将其中任意数量的牌以任意顺序置于牌堆顶，其余以任意顺序置于牌堆底。",


  ["thbattle__bayunlan_jizhi"] = "极智",
  ["#thbattle__bayunlan_jizhi-discard"] = "极智:你可以弃置一张牌，视为对%src使用一张【%arg】",
  ["#thbattle__bayunlan_jizhi"] = "极智:你可以弃置一张牌，视为对%src使用一张【%arg】",
  ["$thbattle__bayunlan_jizhi"] = "这个我也会~",
  [":thbattle__bayunlan_jizhi"] = "每轮限一次，你的回合外，当非延时【<a href='thbattle_fuka'><font color='red'>符卡</font></a>】效果对一名角色生效后，你可以弃置一张牌，" ..
      "令该【<a href='thbattle_fuka'><font color='red'>符卡</font></a>】效果对那名角色重新进行一次结算，此时使用者视为你。",

  ["thbattle__bayunlan_suluo"] = "素裸",
  ["$thbattle__bayunlan_suluo"] = "浪费粮食，可不是好行为哟~~",
  [":thbattle__bayunlan_suluo"] = "锁定技，若你没有手牌，【<a href='thbattle_fuka'><font color='red'>符卡</font></a>】对你造成的伤害-1。",
}


-- 节操满地跑的城管 博丽灵梦 体力：4

-- 退治：其他角色的回合内，你可以于以下时机无视距离对其使用一张弹幕：
-- >> 出牌阶段，你受到伤害后。
-- >> 回合结束阶段，且该角色本回合对其他角色造成过伤害。

-- 快晴：你对一名其他角色造成伤害后，你可以与其各摸一张牌，若此时位于其它角色的出牌阶段，停止当前结算并结束出牌阶段。

-- 纳奉：BOSS技，其他角色的出牌阶段限一次，若你的手牌数小于体力上限，其可以将一张手牌置入你的明牌区。

-- （画师：和茶，CV：shourei小N）

local thbattle__lingmeng = General:new(extension, "thbattle__lingmeng", "tho", 4, 4, 2)

local thbattle__lingmeng_tuizhi = fk.CreateTriggerSkill {
  name = "thbattle__lingmeng_tuizhi",
  anim_type = "masochism",
  events = { fk.Damaged, fk.EventPhaseEnd },
  can_trigger = function(self, event, target, player, data)
    self.cost_data = Fk:currentRoom().current
    if event == fk.Damaged then
      return player.phase == Player.NotActive and target == player and player:hasSkill(self) and
          not player:isProhibited(Fk:currentRoom().current, Fk:cloneCard("slash"))
    else
      return #player.room.logic:getActualDamageEvents(1, function(e)
            return e.data[1].from == target and  e.data[1].to ~= target
          end, Player.HistoryTurn) > 0 and not player:isProhibited(target, Fk:cloneCard("slash"))
          and player:hasSkill(self) and player.phase == Player.NotActive and target ~= player and
          target.phase == Player.Finish
    end
  end,
  on_cost = function(self, event, target, player, data)
    local usecard = player.room:askForUseCard(player, "slash", nil, "#thbattle__lingmeng_tuizhi:" ..
      self.cost_data.id, true,
      { bypass_distances = true, must_targets = { self.cost_data.id } })
    self.cost_data = usecard
    return usecard and usecard.card
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:useCard(self.cost_data)
  end
}

local thbattle__lingmeng_kuaiqing = fk.CreateTriggerSkill {
  name = "thbattle__lingmeng_kuaiqing",
  anim_type = "drawcard",
  events = { fk.Damage },
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and data.to ~= player
  end,
  on_cost = function(self, event, target, player, data)
    local prompt = "#thbattle__lingmeng_kuaiqing1:" .. data.to.id
    if player.phase == Player.NotActive then
      prompt = "#thbattle__lingmeng_kuaiqing2:" .. data.to.id .. ":" .. Fk:currentRoom().current.id
    end
    return player.room:askForSkillInvoke(player, self.name, nil, prompt)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:drawCards(1, self.name)
    data.to:drawCards(1, self.name)
    if player.phase == Player.NotActive and Fk:currentRoom().current.id ~ player.id and Fk:currentRoom().current.phase == Player.Play then
      local event = room.logic:getCurrentEvent():findParent(GameEvent.Phase)
      if not event then return end
      event:shutdown()
    end
  end,
}

local thbattle__lingmeng_nafeng = fk.CreateTriggerSkill {
  name = "thbattle__lingmeng_nafeng$",
  mute = true,
  attached_skill_name = "thbattle__lingmeng_nafeng_rule&",
  events = { fk.AfterCardsMove },
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) then
      for _, move in ipairs(data) do
        if move.from and move.to == player.id and move.toArea == Card.PlayerHand and move.proposer == move.from and move.skillName == "thbattle__lingmeng_nafeng_rule&" then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.PlayerHand and Fk:getCardById(info.cardId).name == "exinwan" then
              return true
            end
          end
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:broadcastPlaySound("packages/thbattle/audio/skill/thbattle__lingmeng_nafeng1")
  end,

}

local thbattle__lingmeng_nafeng_rule = fk.CreateActiveSkill {
  name = "thbattle__lingmeng_nafeng_rule&",
  prompt = function(self, selected_cards, selected_targets)
    local target
    for _, p in ipairs(Fk:currentRoom().alive_players) do
      if p:hasSkill("thbattle__lingmeng_nafeng") and p.role == "lord" then
        target = p
        break
      end
    end
    return "#thbattle__lingmeng_nafeng_rule&:" .. target.id
  end,
  anim_type = "support",
  card_num = 1,
  card_filter =function (self, to_select, selected, user)
    return #selected == 0 and table.contains(user:getCardIds("h"), to_select)
  end,
  target_num = 1,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, user)
    local room = Fk:currentRoom()
    return #selected == 0 and to_select ~= user.id and
        room:getPlayerById(to_select):hasSkill("thbattle__lingmeng_nafeng")
        and room:getPlayerById(to_select).role == "lord"
  end,
  can_use = function(self, player, card, extra_data)
    for _, p in ipairs(Fk:currentRoom().alive_players) do
      if p:hasSkill("thbattle__lingmeng_nafeng") and p.role == "lord" then
        return player:usedSkillTimes(self.name, Player.phase) == 0 and #p:getCardIds("h") < p.maxHp
      end
    end
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    room:broadcastPlaySound("packages/thbattle/audio/skill/thbattle__lingmeng_nafeng" .. math.random(2, 3))
    room:moveCardTo(effect.cards, Card.PlayerHand, target, fk.ReasonGive, self.name, nil, true, player.id,
      "@@thb_mingpai")
  end,
}

Fk:addSkill(thbattle__lingmeng_nafeng_rule)

thbattle__lingmeng:addSkill(thbattle__lingmeng_tuizhi)
thbattle__lingmeng:addSkill(thbattle__lingmeng_kuaiqing)
thbattle__lingmeng:addSkill(thbattle__lingmeng_nafeng)

Fk:loadTranslationTable {
  ["thbattle__lingmeng"] = "博丽灵梦",
  ["#thbattle__lingmeng"] = "节操满地跑的城管",
  ["~thbattle__lingmeng"] = "我的~~赛钱箱————",
  ["designer:thbattle__lingmeng"] = "Rem",
  ["cv:thbattle__lingmeng"] = "shourei小N",
  ["illustrator:thbattle__lingmeng"] = "和茶",


  ["thbattle__lingmeng_tuizhi"] = "退治",
  ["$thbattle__lingmeng_tuizhi1"] = "你的十万，好像还没交吧~",
  ["$thbattle__lingmeng_tuizhi2"] = "你就是异变的源头吗",
  ["$thbattle__lingmeng_tuizhi3"] = "你这是在自寻死路！",
  [":thbattle__lingmeng_tuizhi"] = "其他角色的回合内，你可以于以下时机无视距离对其使用一张【弹幕】：" ..
      "<font color='red'>>></font> 出牌阶段，你受到伤害后。" ..
      "<font color='red'>>></font> 回合结束阶段，且该角色本回合对其他角色造成过伤害。",
  ["#thbattle__lingmeng_tuizhi"] = "退治:你可以对其使用一张【弹幕】",

  ["thbattle__lingmeng_kuaiqing"] = "快晴",
  ["#thbattle__lingmeng_kuaiqing1"] = "快晴:你可以与【%src】各摸一张牌",
  ["#thbattle__lingmeng_kuaiqing2"] = "快晴:你可以与【%src】各摸一张牌，然后停止当前所有结算并结束【%dest】的出牌阶段。",
  ["$thbattle__lingmeng_kuaiqing"] = "啊~今天的幻想乡真是和平呐",
  [":thbattle__lingmeng_kuaiqing"] = "你对一名其他角色造成伤害后，你可以与其各摸一张牌，若此时位于其它角色的出牌阶段，停止当前结算并结束出牌阶段。",

  ["thbattle__lingmeng_nafeng"] = "纳奉",
  ["thbattle__lingmeng_nafeng_rule&"] = "纳奉",
  [":thbattle__lingmeng_nafeng_rule&"] = "出牌阶段限一次，若灵梦的手牌数小于体力上限，你可以将一张手牌置入灵梦的明牌区。",
  ["#thbattle__lingmeng_nafeng_rule&"] = "纳奉:你可以交给%src一张手牌",
  ["$thbattle__lingmeng_nafeng1"] = "我不是垃圾桶，不是垃圾桶！",
  ["$thbattle__lingmeng_nafeng2"] = "填满我的赛钱箱，共建和谐幻想乡！",
  ["$thbattle__lingmeng_nafeng3"] = "向幻想乡的纳奉人致敬！",
  [":thbattle__lingmeng_nafeng"] = "BOSS技，其他角色的出牌阶段限一次，若你的手牌数小于体力上限，其可以将一张手牌置入你的明牌区。",
}


-- 永远幼小的红月 蕾米莉亚 体力：4

-- 神枪：满足下列条件之一时，你可以令你的弹幕不能被响应：
-- >> 目标角色的体力值 大于 你的体力值。
-- >> 目标角色的手牌数 小于 你的手牌数。

-- 红魔之吻：锁定技，你使用红色弹幕时无距离限制。当你使用红色弹幕对一名其他角色造成伤害后，你回复1点体力。

-- 红雾：BOSS技，限定技，出牌阶段，你可以选择至多X名其他角色（X为存活道中数量），直到你的下个回合开始阶段，所有角色受到以下影响：
-- >> 你与被选择的角色使用弹幕时无视距离，且使用弹幕造成伤害后回复等量的体力。
-- >> 其他角色使用弹幕时只能指定距离为1的目标。

-- （画师：小D@星の妄想乡，CV：VV）

local thbattle__leimi = General:new(extension, "thbattle__leimi", "tho", 4, 4, 2)

local thbattle__leimi_shenqiang = fk.CreateTriggerSkill {
  name = "thbattle__leimi_shenqiang",
  anim_type = "offensive",
  prompt = "#thbattle__leimi_shenqiang",
  events = { fk.TargetSpecified },
  can_trigger = function(self, event, target, player, data)
    if not (target == player and player:hasSkill(self) and data.card.trueName == "slash") then return end
    local target_player = player.room:getPlayerById(data.to)
    return target_player.hp > player.hp or #target_player:getCardIds("h") <
        #player:getCardIds("h")
  end,
  on_use = function(self, event, target, player, data)
    data.disresponsiveList = data.disresponsiveList or {}
    table.insert(data.disresponsiveList, data.to)
  end,
}

local thbattle__leimi_hongmo = fk.CreateTriggerSkill {
  name = "thbattle__leimi_hongmo",
  anim_type = "offensive",
  frequency = Skill.Compulsory,
  events = { fk.Damage },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card and data.card.trueName == "slash" and
        data.card.color == Card.Red
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:recover({
      who = player,
      num = 1,
      recoverBy = player,
      skillName = self.name
    })
  end,
}

local thbattle__leimi_hongmo_distance = fk.CreateTargetModSkill {
  name = "#thbattle__leimi_hongmo_distance",
  bypass_distances = function(self, player, skill, card, to)
    return player:hasSkill(thbattle__leimi_hongmo) and card.trueName == "slash" and card.color == Card.Red
  end
}

local thbattle__leimi_hongwu = fk.CreateActiveSkill {
  name = "thbattle__leimi_hongwu$",
  anim_type = "big",
  frequency = Skill.Limited,
  prompt = "#thbattle__leimi_hongwu",
  max_game_use_time = 1,
  min_target_num = 1,
  max_target_num = function()
    return #table.filter(Fk:currentRoom().alive_players, function(p)
      return p.role == "loyalist"
    end)
  end,
  target_filter = function(self, to_select, selected, selected_cards, card, extra_data,user)
    return #selected < #table.filter(Fk:currentRoom().alive_players, function(p)
      return p.role == "loyalist"
    end) and user.id ~= to_select
  end,
  card_filter = Util.FalseFunc,
  can_use = function(self, player, card, extra_data)
    return player.role == "lord" and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    THB_Utility.addStatusMark(player, "@@thbattle__leimi_hongwu1")
    for _, to in ipairs(effect.tos) do
      local target = room:getPlayerById(to)
      THB_Utility.addStatusMark(target, "@@thbattle__leimi_hongwu1")
    end
    for _, p in ipairs(room.alive_players) do
      if p:getMark("@@thbattle__leimi_hongwu1") == 0 then
        room:addPlayerMark(p, "@@thbattle__leimi_hongwu2")
      end
    end
  end,

}

local thbattle__leimi_hongwu_trigger = fk.CreateTriggerSkill {
  name = "#thbattle__leimi_hongwu_trigger",
  frequency = Skill.Compulsory,
  events = { fk.Damage },
  global = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:getMark("@@thbattle__leimi_hongwu1") > 0 and data.card and
        data.card.trueName == "slash"
  end,
  on_use = function(self, event, target, player, data)
    player.room:notifySkillInvoked(player, self.name, "support")
    player.room:recover({
      who = player,
      num = data.damage,
      recoverBy = player,
      skillName = self.name,
    })
  end,


}

local thbattle__leimi_hongwu_distance = fk.CreateTargetModSkill {
  name = "#thbattle__leimi_hongwu_distance",
  bypass_distances = function(self, player, skill, card, to)
    return player:getMark("@@thbattle__leimi_hongwu1") > 0 and card.trueName == "slash"
  end,
}

local thbattle__leimi_hongwu_prohibit = fk.CreateProhibitSkill {
  name = "#thbattle__leimi_hongwu_prohibit",
  is_prohibited = function(self, from, to, card)
    return from:getMark("@@thbattle__leimi_hongwu2") > 0 and from:distanceTo(to) > 1 and card.trueName == "slash"
  end
}


local thbattle__leimi_hongwu_clear = fk.CreateTriggerSkill {
  name = "#thbattle__leimi_hongwu_clear",
  global = true,
  refresh_events = { fk.TurnStart },
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(thbattle__leimi_hongwu) and player:hasSkill(thbattle__leimi_hongwu) and
        player:usedSkillTimes("thbattle__leimi_hongwu", Player.HistoryGame) == 1
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    for _, p in ipairs(player.room.alive_players) do
      if p:getMark("@@thbattle__leimi_hongwu1") > 0 then
        THB_Utility.removePlayerMark(p, "@@thbattle__leimi_hongwu1")
      elseif p:getMark("@@thbattle__leimi_hongwu2") > 0 then
        room:removePlayerMark(p, "@@thbattle__leimi_hongwu2")
      end
    end
  end,
}


Fk:addSkill(thbattle__leimi_hongwu_clear)
thbattle__leimi_hongwu:addRelatedSkill(thbattle__leimi_hongwu_trigger)
thbattle__leimi_hongwu:addRelatedSkill(thbattle__leimi_hongwu_distance)
thbattle__leimi_hongwu:addRelatedSkill(thbattle__leimi_hongwu_prohibit)
thbattle__leimi_hongmo:addRelatedSkill(thbattle__leimi_hongmo_distance)
thbattle__leimi:addSkill(thbattle__leimi_shenqiang)
thbattle__leimi:addSkill(thbattle__leimi_hongmo)
thbattle__leimi:addSkill(thbattle__leimi_hongwu)

Fk:loadTranslationTable {
  ["thbattle__leimi"] = "蕾米莉亚",
  ["#thbattle__leimi"] = "永远幼小的红月",
  ["~thbattle__leimi"] = "自古枪兵，幸运E嘛...",
  ["designer:thbattle__leimi"] = "Rem",
  ["cv:thbattle__leimi"] = "VV",
  ["illustrator:thbattle__leimi"] = "小D@星の妄想乡",


  ["thbattle__leimi_shenqiang"] = "神枪",
  ["$thbattle__leimi_shenqiang"] = "中！一发入魂",
  [":thbattle__leimi_shenqiang"] = "满足下列条件之一时，你可以令你的【弹幕】不能被响应：" ..
      "<font color='red'>>></font> 目标角色的体力值 大于 你的体力值。" ..
      "<font color='red'>>></font> 目标角色的手牌数 小于 你的手牌数。",
  ["#thbattle__leimi_shenqiang"] = "神枪:你可以令你的【弹幕】不能被响应",


  ["thbattle__leimi_hongmo"] = "红魔之吻",
  ["$thbattle__leimi_hongmo"] = "B型血，赞",
  [":thbattle__leimi_hongmo"] = "锁定技，你使用红色【弹幕】时无距离限制。当你使用红色【弹幕】对一名其他角色造成伤害后，你回复1点体力。",

  ["thbattle__leimi_hongwu"] = "红雾",
  ["#thbattle__leimi_hongwu"] = "红雾:你可以选择至多X名其他角色（X为存活道中/忠臣数量），被选中的角色和你拥有增益，其他角色拥有减益",
  ["@@thbattle__leimi_hongwu1"] = "红雾嗜血",
  ["@@thbattle__leimi_hongwu2"] = "红雾遮挡",
  ["#thbattle__leimi_hongwu_trigger"] = "红雾",
  ["$thbattle__leimi_hongwu1"] = "亮一亮，吸血鬼的威严吧~",
  ["$thbattle__leimi_hongwu2"] = "（日语版）亮一亮，吸血鬼的威严吧~",
  [":thbattle__leimi_hongwu"] = "BOSS技，限定技，出牌阶段，你可以选择至多X名其他角色（X为存活道中/忠臣数量），直到你的下个回合开始阶段，所有角色受到以下影响：<br/>" ..
      "<font color='red'>>></font> 你与被选择的角色使用弹幕时无视距离，且使用弹幕造成伤害后回复等量的体力。<br/>" ..
      "<font color='red'>>></font> 其他角色使用弹幕时只能指定距离为1的目标。",
}

-- 完全潇洒的PAD长 十六夜咲夜 体力：4

-- 飞刀：你可以将一张装备牌当弹幕使用或打出，以此法使用的弹幕无距离限制。

-- 月时计：锁定技，准备阶段开始时，你执行一个额外的出牌阶段。

-- （画师：和茶，CV：VV）

local thbattle__xiaoye = General:new(extension, "thbattle__xiaoye", "tho", 4, 4, 2)

local thbattle__xiaoye_feidao = fk.CreateViewAsSkill {
  name = "thbattle__xiaoye_feidao",
  anim_type = "offensive",
  pattern = "slash",
  prompt = "#thbattle__xiaoye_feidao",
  card_filter =function (self, to_select, selected, player)
    if #selected == 1 then return false end
    return Fk:getCardById(to_select).type == Card.TypeEquip
  end,
  view_as = function(self, cards,user)
    if #cards ~= 1 then return nil end
    local c = Fk:cloneCard("danmu__slash")
    c.skillName = self.name
    c:addSubcard(cards[1])
    return c
  end,
}

local thbattle__xiaoye_feidao__distance = fk.CreateTargetModSkill {
  name = "#thbattle__xiaoye_feidao__distance",
  bypass_distances = function(self, player, skill, card, to)
    return player:hasSkill(thbattle__xiaoye_feidao) and card.skillName == "thbattle__xiaoye_feidao"
  end
}

local thbattle__xiaoye_yuejishi = fk.CreateTriggerSkill {
  name = "thbattle__xiaoye_yuejishi",
  anim_type = "offensive",
  frequency = Skill.Compulsory,
  events = { fk.EventPhaseStart },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Start
  end,
  on_use = function(self, event, target, player, data)
    player:gainAnExtraPhase(Player.Play)
  end,

  refresh_events = { fk.EventPhaseStart },
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Play and
        player:getMark("thbattle__xiaoye_yuejishi-turn") == 0
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    room:addPlayerMark(player, "@!thbattle__xiaoye_yuejishi-phase")
    room:addPlayerMark(player, "thbattle__xiaoye_yuejishi-turn")
  end
}

thbattle__xiaoye_feidao:addRelatedSkill(thbattle__xiaoye_feidao__distance)
thbattle__xiaoye:addSkill(thbattle__xiaoye_feidao)
thbattle__xiaoye:addSkill(thbattle__xiaoye_yuejishi)

Fk:loadTranslationTable {
  ["thbattle__xiaoye"] = "十六夜咲夜",
  ["#thbattle__xiaoye"] = "完全潇洒的PAD长",
  ["~thbattle__xiaoye"] = "咲夜，红茶，咲夜？",
  ["designer:thbattle__xiaoye"] = "Rem",
  ["cv:thbattle__xiaoye"] = "VV",
  ["illustrator:thbattle__xiaoye"] = "和茶",


  ["thbattle__xiaoye_feidao"] = "飞刀",
  ["$thbattle__xiaoye_feidao1"] = "我的这把刀，可是涂满了毒药的毒刃",
  ["$thbattle__xiaoye_feidao2"] = "PAD丢出去，也是可以伤人的！",
  [":thbattle__xiaoye_feidao"] = "你可以将一张装备牌当【弹幕】使用或打出，以此法使用的【弹幕】无距离限制。",
  ["#thbattle__xiaoye_feidao"] = "飞刀:你可以将一张装备牌当【弹幕】使用或打出，以此法使用的【弹幕】无距离限制。",


  ["thbattle__xiaoye_yuejishi"] = "月时计",
  ["$thbattle__xiaoye_yuejishi"] = "现在是咲夜的时间！",
  [":thbattle__xiaoye_yuejishi"] = "锁定技，准备阶段开始时，你执行一个额外的出牌阶段。",
}


-- 常识满满的现人神 东风谷早苗 体力：3

-- 奇迹：出牌阶段，你可以弃置X张牌并摸一张牌；若X为3，你可以令一名角色回复1点体力。（X为你此阶段使用奇迹的次数,至少为1）

-- 信仰：出牌阶段限一次，你可以令至多两名其他角色各交给你一张手牌，然后你交给其各一张牌。

-- 神裔：每当你成为群体符卡的目标后，你可以重铸一张牌并跳过此次结算。

-- （画师：小D@星の妄想乡，CV：VV）

local thbattle__zaomiao = General:new(extension, "thbattle__zaomiao", "tho", 3, 3, 2)

local thbattle__zaomiao_qiji = fk.CreateActiveSkill {
  name = "thbattle__zaomiao_qiji",
  prompt = function(self, selected_cards, selected_targets)
    return "#thbattle__zaomiao_qiji:::" .. Self:usedSkillTimes(self.name, Player.HistoryPhase) + 1
  end,
  target_filter = Util.FalseFunc,
  card_num = function()
    return Self:usedSkillTimes("thbattle__zaomiao_qiji", Player.HistoryPhase) + 1
  end,
  card_filter =function (self, to_select, selected, user)
    return #selected < user:usedSkillTimes("thbattle__zaomiao_qiji", Player.HistoryPhase) + 1
  end,
  anim_type = "drawcard",
  can_use = function(self, player, card, extra_data)
    return #player:getCardIds("he") >= player:usedSkillTimes(self.name, Player.HistoryPhase) + 1
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    room:throwCard(effect.cards, self.name, player, player)
    player:drawCards(1, self.name)
    if player:usedSkillTimes(self.name, Player.HistoryPhase) == 3 then
      local target_players = table.filter(room.alive_players, function(p)
        return p:isWounded()
      end)
      if #target_players > 0 then
        local target = room:askForChoosePlayers(player, table.map(target_players, Util.IdMapper), 1, 1,
          "#thbattle__zaomiao_qiji-choose_player", self.name, true)
        if #target > 0 then
          room:recover({
            who = room:getPlayerById(target[1]),
            num = 1,
            recoverBy = player,
            skillName = self.name
          })
        end
      end
    end
  end,
}

local thbattle__zaomiao_xinyang = fk.CreateActiveSkill {
  name = "thbattle__zaomiao_xinyang",
  prompt = "#thbattle__zaomiao_xinyang",
  min_target_num = 1,
  max_target_num = 2,
  target_filter = function(self, to_select, selected, selected_cards, card, extra_data,user)
    return #selected < 2 and not Fk:currentRoom():getPlayerById(to_select):isKongcheng() and to_select ~= user.id
  end,
  card_filter = Util.FalseFunc,
  anim_type = "control",
  max_phase_use_time = 1,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    for _, pid in ipairs(effect.tos) do
      local target = room:getPlayerById(pid)
      local target_card = room:askForCard(target, 1, 1, false, self.name, false, ".",
        "#thbattle__zaomiao_xinyang-target_choose_card:" .. player.id)
      room:obtainCard(player, target_card, false, fk.ReasonGive, player.id, self.name)
    end
    for _, pid in ipairs(effect.tos) do
      local target = room:getPlayerById(pid)
      local target_card = room:askForCard(player, 1, 1, true, self.name, false, ".",
        "#thbattle__zaomiao_xinyang-player_give_card:" .. target.id)
      room:obtainCard(target, target_card, false, fk.ReasonGive, player.id, self.name)
    end
  end,
}

local thbattle__zaomiao_shenyi = fk.CreateTriggerSkill {
  name = "thbattle__zaomiao_shenyi",
  anim_type = "defensive",
  events = { fk.TargetConfirmed },
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and data.card and data.card.type == Card.TypeTrick and
        data.card.multiple_targets == true and
        target == player
  end,
  on_cost = function(self, event, target, player, data)
    local cost_card = player.room:askForCard(player, 1, 1, true, self.name, true, ".",
      "#thbattle__zaomiao_shenyi-invokeSkill:::" .. data.card:toLogString())
    self.cost_data = cost_card
    return #cost_card > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:recastCard(self.cost_data, player, self.name)
    AimGroup:cancelTarget(data, player.id)
  end,
}

thbattle__zaomiao:addSkill(thbattle__zaomiao_qiji)
thbattle__zaomiao:addSkill(thbattle__zaomiao_xinyang)
thbattle__zaomiao:addSkill(thbattle__zaomiao_shenyi)

Fk:loadTranslationTable {
  ["thbattle__zaomiao"] = "东风谷早苗",
  ["#thbattle__zaomiao"] = "常识满满的现人神",
  ["~thbattle__zaomiao"] = "神奈子大人..咳咳..诹访子大人~~",
  ["designer:thbattle__zaomiao"] = "Rem",
  ["cv:thbattle__zaomiao"] = "VV",
  ["illustrator:thbattle__zaomiao"] = "小D@星の妄想乡",


  ["thbattle__zaomiao_qiji"] = "奇迹",
  ["$thbattle__zaomiao_qiji"] = "奇迹，是存在的！",
  [":thbattle__zaomiao_qiji"] = "出牌阶段，你可以弃置X张牌并摸一张牌；若X为3，你可以令一名角色回复1点体力。（X为你此阶段使用奇迹的次数,至少为1）",
  ["#thbattle__zaomiao_qiji"] = "奇迹:你可以弃置%arg张牌并摸一张牌；若弃置牌数为3，你可以令一名角色回复1点体力。",
  ["#thbattle__zaomiao_qiji-choose_player"] = "奇迹:你可以令一名角色回复1点体力。",


  ["thbattle__zaomiao_xinyang"] = "信仰",
  ["$thbattle__zaomiao_xinyang"] = "收集信仰哪家强，守矢神社早苗教~",
  [":thbattle__zaomiao_xinyang"] = "出牌阶段限一次，你可以令至多两名其他角色各交给你一张手牌，然后你交给其各一张牌。",
  ["#thbattle__zaomiao_xinyang"] = "信仰：你可以令至多两名其他角色各交给你一张手牌，然后你交给其各一张牌。",
  ["#thbattle__zaomiao_xinyang-target_choose_card"] = "信仰：你交给%src一张手牌，然后其交给你一张牌。",
  ["#thbattle__zaomiao_xinyang-player_give_card"] = "信仰:你交给%src一张牌",

  ["thbattle__zaomiao_shenyi"] = "神裔",
  ["$thbattle__zaomiao_shenyi1"] = "这是神风的庇护！",
  ["$thbattle__zaomiao_shenyi2"] = "这是大地的恩赐！",
  [":thbattle__zaomiao_shenyi"] = "每当你成为群体【<a href='thbattle_fuka'><font color='red'>符卡</font></a>】的目标后，你可以重铸一张牌并跳过此次结算。",
  ["#thbattle__zaomiao_shenyi-invokeSkill"] = "神裔:你可以重铸一张牌，跳过【%arg】的结算",

}


-- 僵尸别跑 霍青娥 体力：4

-- 邪仙：出牌阶段，你可以将一张手牌以一名其他角色的身份使用。
-- >> 以此法使用弹幕消耗你的干劲。
-- >> 你成为此法使用的群体符卡的目标后，可以跳过此次结算。

-- 通灵：限定技，你的回合内，当有角色被击坠时，你可以获得其一个技能。（不包括限定技，觉醒技）

-- （画师：和茶，CV：小羽）

local thbattle__huoqinge = General:new(extension, "thbattle__huoqinge", "tho", 4, 4, 2)

local thbattle__huoqinge_xiexian = fk.CreateActiveSkill {
  name = "thbattle__huoqinge_xiexian",
  anim_type = "control",
  prompt = "#thbattle__huoqinge_xiexian-active",
  card_filter = Util.FalseFunc,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, player)
    return #selected == 0 and to_select ~= player.id
  end,
  target_num = 1,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = effect.tos[1]
    room:setPlayerMark(player, "thbattle__huoqinge_xiexian_target", target)
    local general_info = { player.general, player.deputyGeneral }
    local tar_player = room:getPlayerById(target)
    player.general = tar_player.general
    player.deputyGeneral = tar_player.deputyGeneral
    room:broadcastProperty(player, "general")
    room:broadcastProperty(player, "deputyGeneral")
    local _, ret = room:askForUseActiveSkill(player, "thbattle__huoqinge_xiexian_use",
      "#thbattle__huoqinge_xiexian-use:" .. target, true)
    room:setPlayerMark(player, "thbattle__huoqinge_xiexian_target", 0)
    player.general = general_info[1]
    player.deputyGeneral = general_info[2]
    room:broadcastProperty(player, "general")
    room:broadcastProperty(player, "deputyGeneral")
    if ret then
      local use_card = Fk:getCardById(ret.cards[1])
      local slash = Fk:cloneCard("slash")
      room:doBroadcastNotify("ShowToast", "以【邪仙】使用的【杀】会计入你的【杀】使用次数")
      if use_card.trueName == "slash" and
          THB_Utility.withinTimesLimit(player, Player.HistoryPhase, slash, "slash", room:getPlayerById(ret.targets[1]), slash.skill, 1) then
        room:addCardMark(use_card, "@@thbattle__huoqinge_xiexian")
        player:addCardUseHistory("slash", 1)
        room:useCard({
          from = target,
          tos = table.map(ret.targets, function(pid) return { pid } end),
          card = use_card,
        })
      elseif use_card.trueName == "slash" then
        room:doBroadcastNotify("ShowToast", "本次使用失败")
      else
        room:useCard({
          from=target,
          tos=table.map(ret.targets, function(id) return {id} end),
          card=Fk:getCardById(ret.cards[1]),
          extraUse=true
        })
      end
    end
  end,
}

local thbattle__huoqinge_xiexian_m_p_c = fk.CreateTriggerSkill {
  name = "#thbattle__huoqinge_xiexian_m_p_c",
  frequency = Skill.Compulsory,
  mute = true,
  events = { fk.BeforeCardUseEffect },
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(thbattle__huoqinge_xiexian) and data.card and
        data.card:getMark("@@thbattle__huoqinge_xiexian") > 0 and data.card.multiple_targets == true
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local tos_sort, temp = {}, target
    if table.find(data.tos, function(e)
          return room:getPlayerById(e[1]) == target
        end) then
      table.insert(tos_sort, { target.id })
    end
    while true do
      temp = temp.next
      if temp == target then
        break
      end
      if table.find(data.tos, function(e)
            return room:getPlayerById(e[1]) == temp
          end) then
        table.insert(tos_sort, { temp.id })
      end
    end
    data.tos = tos_sort
  end,

}


local thbattle__huoqinge_xiexian_targetmod = fk.CreateTriggerSkill {
  name = "#thbattle__huoqinge_xiexian_targetmod",
  anim_type = "defensive",
  events = { fk.TargetConfirmed },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(thbattle__huoqinge_xiexian) and data.card and
        data.card:getMark("@@thbattle__huoqinge_xiexian") > 0 and data.card.multiple_targets == true
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil,
      "#thbattle__huoqinge_xiexian_targetmod-use:::" .. data.card:toLogString())
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    AimGroup:cancelTarget(data, player.id)
  end,
}

local thbattle__huoqinge_xiexian_use = fk.CreateActiveSkill {
  name = "thbattle__huoqinge_xiexian_use",
  card_filter =function (self, to_select, selected, player)
    if #selected > 0 then return false end
    local room = Fk:currentRoom()
    if room:getCardArea(to_select) == Card.PlayerEquip then return false end
    local target_id = player:getMark("thbattle__huoqinge_xiexian_target")
    local target = room:getPlayerById(target_id)
    local card = Fk:getCardById(to_select)
    return target:canUse(card) and not target:prohibitUse(card)
  end,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, player)
    if #selected_cards ~= 1 then return false end
    local card = Fk:getCardById(selected_cards[1])
    local card_skill = card.skill
    local room = Fk:currentRoom()
    local target_id = player:getMark("thbattle__huoqinge_xiexian_target")
    local target = room:getPlayerById(target_id)
    if card_skill:getMinTargetNum() == 0 or #selected >= card_skill:getMaxTargetNum(target, card) then return false end
    return not target:isProhibited(room:getPlayerById(to_select), card) and
        card_skill:modTargetFilter(to_select, selected, target, card, true)
  end,
  feasible =function (self, selected, selected_cards, player)
    if #selected_cards ~= 1 then return false end
    local card = Fk:getCardById(selected_cards[1])
    local card_skill = card.skill
    local room = Fk:currentRoom()
    local target_id = player:getMark("thbattle__huoqinge_xiexian_target")
    local target = room:getPlayerById(target_id)
    return #selected >= card_skill:getMinTargetNum() and #selected <= card_skill:getMaxTargetNum(target, card)
  end,
}


local thbattle__huoqinge_tongling = fk.CreateTriggerSkill {
  name = "thbattle__huoqinge_tongling",
  frequency = Skill.Limited,
  anim_type = "big",
  events = { fk.Death },
  can_trigger = function(self, event, target, player, data)
    return target ~= player and player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#thbattle__huoqinge_tongling:" .. target.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local p = target
    room:doIndicate(player.id, { p.id })
    local skills = {}
    --加载技能
    for _, skill in ipairs(p.player_skills) do
      if not (skill.attached_equip or skill.name[#skill.name] == "&") and
          (#skill.attachedKingdom == 0 or table.contains(skill.attachedKingdom, player.kingdom)) and
          (skill.frequency ~= Skill.Wake or skill.frequency ~= Skill.Limited or skill.frequency ~= Skill.Quest) then
        table.insertIfNeed(skills, skill.name)
      end
    end
    if #skills > 0 then
      local choices
      local result = player.room:askForCustomDialog(player, self.name,
        "packages/tenyear/qml/ChooseGeneralSkillsBox.qml", {
          { p.general }, { skills }, 1, 1, "#thbattle__huoqinge_tongling-choice", false
        })
      if result ~= "" then
        choices = json.decode(result)
      end
      if choices~=nil then
        room:handleAddLoseSkills(player, table.concat(choices, "|"), nil)
      end
    end
  end,
}


Fk:addSkill(thbattle__huoqinge_xiexian_use)
thbattle__huoqinge_xiexian:addRelatedSkill(thbattle__huoqinge_xiexian_targetmod)
thbattle__huoqinge_xiexian:addRelatedSkill(thbattle__huoqinge_xiexian_m_p_c)
thbattle__huoqinge:addSkill(thbattle__huoqinge_xiexian)
thbattle__huoqinge:addSkill(thbattle__huoqinge_tongling)
Fk:loadTranslationTable {
  ["thbattle__huoqinge"] = "霍青娥",
  ["#thbattle__huoqinge"] = "僵尸别跑",
  ["~thbattle__huoqinge"] = "渡劫~失败了吗",
  ["designer:thbattle__huoqinge"] = "Rem",
  ["cv:thbattle__huoqinge"] = "小羽",
  ["illustrator:thbattle__huoqinge"] = "和茶",


  ["thbattle__huoqinge_xiexian"] = "邪仙",
  ["$thbattle__huoqinge_xiexian"] = "嘴上说不，身体还是很诚实的嘛~",
  [":thbattle__huoqinge_xiexian"] = "出牌阶段，你可以将一张手牌以一名其他角色的身份使用。" ..
      "<font color='red'>>></font> 以此法使用弹幕消耗你的干劲。" ..
      "<font color='red'>>></font> 你成为此法使用的群体符卡的目标后，可以跳过此次结算。",
  ["#thbattle__huoqinge_xiexian"] = "邪仙:你可以将一张手牌以一名其他角色的身份使用。",
  ["#thbattle__huoqinge_xiexian-active"] = "邪仙:你可以将一张手牌以一名其他角色的身份使用。",
  ["#thbattle__huoqinge_xiexian-use"] = "邪仙:你可以令【%src】使用卡牌。",
  ["thbattle__huoqinge_xiexian-use"] = "邪仙",
  ["@@thbattle__huoqinge_xiexian"] = "邪仙",
  ["#thbattle__huoqinge_xiexian_targetmod"] = "邪仙",
  ["#thbattle__huoqinge_xiexian_targetmod-use"] = "邪仙：你可以跳过【%arg】结算",


  ["thbattle__huoqinge_tongling"] = "通灵",
  ["$thbattle__huoqinge_tongling"] = "收集信仰哪家强，守矢神社早苗教~",
  [":thbattle__huoqinge_tongling"] = "限定技，你的回合内，当有角色被击坠时，你可以获得其一个技能。（不包括限定技，觉醒技，使命技，主公技等）",
  ["#thbattle__huoqinge_tongling"] = "通灵：你可以获得【%src】一个技能",
  ["#thbattle__huoqinge_tongling-choice"] = "通灵：选择【%src】一个技能并获得",

}


local thbattle__parsee = General(extension, "thbattle__parsee", "tho", 4, 4, 2)

local thbattle__parsee_jidu = fk.CreateViewAsSkill {
  name = "thbattle__parsee_jidu",
  anim_type = "control",
  pattern = "dismantlement",

  card_filter =function (self, to_select, selected, player)
    if #selected == 1 then return false end
    return Fk:getCardById(to_select).color == Card.Black
  end,

  view_as = function(self, cards,user)
    if #cards ~= 1 then return nil end
    local c = Fk:cloneCard("chengguanzhifa__dismantlement")
    c.skillName = self.name
    c:addSubcard(cards[1])
    return c
  end,
  enabled_at_response = function(self, player, response)
    return not response
  end
}

local thbattle__parsee_jidu_trigger = fk.CreateTriggerSkill {
  name = "#thbattle__parsee_jidu_trigger",
  anim_type = "drawcard",
  events = { fk.AfterCardsMove },
  prompt = "#thbattle__parsee_jidu_trigger-prompt",
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(thbattle__parsee_jidu) then return false end
    for _, move in ipairs(data) do
      if move.from and move.from ~= player.id and player:distanceTo(player.room:getPlayerById(move.from)) == 1
          and move.moveReason == fk.ReasonDiscard and move.proposer == player.id and move.skillName == "dismantlement_skill" then
        for _, info in ipairs(move.moveInfo) do
          if Fk:getCardById(info.cardId).suit == Card.Diamond and player.room:getCardArea(info.cardId) == Card.DiscardPile and
              #U.moveCardsHoldingAreaCheck(player.room, { info.cardId }) > 0 then
            return true
          end
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    for _, move in ipairs(data) do
      if move.from and move.from ~= player.id and player:distanceTo(player.room:getPlayerById(move.from)) == 1
          and (move.toArea == Card.DiscardPile or move.toArea == Card.DrawPile) and move.moveReason == fk.ReasonDiscard
          and move.proposer == player.id and move.skillName == "dismantlement_skill" then
        for _, info in ipairs(move.moveInfo) do
          if Fk:getCardById(info.cardId).suit == Card.Diamond and player.room:getCardArea(info.cardId) == Card.DiscardPile
              and #U.moveCardsHoldingAreaCheck(player.room, { info.cardId }) > 0 then
            player.room:obtainCard(player, info.cardId, true, fk.ReasonPrey, player.id,
              "thbattle__parsee_jidu")
          end
        end
      end
    end
  end
}

thbattle__parsee_jidu:addRelatedSkill(thbattle__parsee_jidu_trigger)
thbattle__parsee:addSkill(thbattle__parsee_jidu)

Fk:loadTranslationTable {
  ["thbattle__parsee"] = "水桥帕露西",
  ["#thbattle__parsee"] = "地壳下的嫉妒心",
  ["designer:thbattle__parsee"] = "失心",
  ["cv:thbattle__parsee"] = "小羽",
  ["illustrator:thbattle__parsee"] = "和茶",
  ["thbattle__parsee_jidu"] = "嫉妒",
  [":thbattle__parsee_jidu"] = "你可以将一张黑色牌当【城管执法】(过河拆桥)使用；每当距离1的其他角色的方块牌被你使用的【城管执法】弃置而置入弃牌堆后，你可以获得之。",
  ["#thbattle__parsee_jidu-obtain"] = "嫉妒：你可以获得一张被弃置的方块牌",
  ["$thbattle__parsee_jidu"] = "你的牌那么多，真是让人不爽呢！",
  ["~thbattle__parsee"] = "为什么中枪的不是他们！？",
  ["#thbattle__parsee_jidu_trigger"] = "嫉妒",
  ["#thbattle__parsee_jidu_trigger-prompt"] = "嫉妒:每当距离1的其他角色的方块牌被你使用的【城管执法】弃置而置入弃牌堆后，你可以获得之。"
}


local thbattle__patchouli = General:new(extension, "thbattle__patchouli", "tho", 3, 3, 2)

local thbattle__patchouli_tushu = fk.CreateTriggerSkill {
  name = "thbattle__patchouli_tushu",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = { fk.CardUsing },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card.type == Card.TypeTrick and
        not data.card.is_delayed_trick
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, self.name)
  end,
}

local thbattle__patchouli_tushu_target = fk.CreateTargetModSkill {
  name = "#thbattle__patchouli_tushu_target",
  frequency = Skill.Compulsory,
  bypass_distances = function(self, player, skill, card)
    return player:hasSkill("thbattle__patchouli_tushu") and card and card.type == Card.TypeTrick
  end,
}

local thbattle__patchouli_boxue = fk.CreateTriggerSkill {
  name = "thbattle__patchouli_boxue",
  anim_type = "defensive",
  frequency = Skill.Compulsory,
  events = { fk.TargetConfirmed },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card and
        data.card.suit == Card.Spade and data.card.type == Card.TypeTrick
  end,
  on_use = function(self, event, target, player, data)
    table.insertIfNeed(data.nullifiedTargets, player.id)
  end,
}


thbattle__patchouli_tushu:addRelatedSkill(thbattle__patchouli_tushu_target)

thbattle__patchouli:addSkill(thbattle__patchouli_tushu)

thbattle__patchouli:addSkill(thbattle__patchouli_boxue)

Fk:loadTranslationTable {
  ["thbattle__patchouli"] = "帕秋莉",
  ["#thbattle__patchouli"] = "不动的大图书馆",
  ["designer:thbattle__patchouli"] = "失心",
  ["cv:thbattle__patchouli"] = "shourei小N",
  ["illustrator:thbattle__patchouli"] = "月见",
  ["thbattle__patchouli_tushu"] = "图书",
  [":thbattle__patchouli_tushu"] = "锁定技，每当你使用非延时符卡时，你摸一张牌；你使用符卡无距离限制。",
  ["thbattle__patchouli_boxue"] = "博学",
  [":thbattle__patchouli_boxue"] = "锁定技，黑桃符卡对你无效。",
  ["$thbattle__patchouli_tushu"] = "图书馆内请保持安静~",
  ["$thbattle__patchouli_boxue"] = "哲学好深奥",
  ["~thbattle__patchouli"] = "为什么中枪的不是他们！？",
}

local thbattle__rinnosuke = General:new(extension, "thbattle__rinnosuke", "tho", 3, 3)

local thbattle__rinnosuke_qinqu = fk.CreateActiveSkill {
  name = "thbattle__rinnosuke_qinqu",
  anim_type = "support",
  prompt = "#thbattle__rinnosuke_qinqu-active",
  max_phase_use_time = 1,
  card_filter =function (self, to_select, selected, player)
    return #selected < 2 and Fk:currentRoom():getCardArea(to_select) == Player.Hand
        and not player:prohibitDiscard(Fk:getCardById(to_select))
  end,
  target_filter =function (self, to_select, selected, selected_cards, card, extra_data, user)
    local target = Fk:currentRoom():getPlayerById(to_select)
    return target:isWounded() and #selected < 1 and to_select ~= user.id
  end,
  target_num = 1,
  card_num = 2,
  on_use = function(self, room, effect)
    local from = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    room:throwCard(effect.cards, self.name, from, from)
    if target:isAlive() and target:isWounded() then
      room:recover({
        who = target,
        num = 1,
        recoverBy = from,
        skillName = self.name
      })
    end
    if from:isAlive() and from:isWounded() then
      room:recover({
        who = from,
        num = 1,
        recoverBy = from,
        skillName = self.name
      })
    end
  end
}




local thbattle__rinnosuke_biantai = fk.CreateTriggerSkill {
  name = "thbattle__rinnosuke_biantai",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = { fk.AfterCardsMove },
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return end
    for _, move in ipairs(data) do
      if move.from == player.id then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerEquip then
            return true
          end
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local i = 0
    for _, move in ipairs(data) do
      if move.from == player.id then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerEquip then
            i = i + 1
          end
        end
      end
    end
    player:drawCards(2 * i, self.name)
  end,
}

thbattle__rinnosuke:addSkill(thbattle__rinnosuke_biantai)

thbattle__rinnosuke:addSkill(thbattle__rinnosuke_qinqu)
Fk:loadTranslationTable {
  ["thbattle__rinnosuke"] = "森近霖之助",
  ["#thbattle__rinnosuke"] = "变态出没注意",
  ["designer:thbattle__rinnosuke"] = "失心",
  ["cv:thbattle__rinnosuke"] = "大白",
  ["illustrator:thbattle__rinnosuke"] = "霏茶",
  ["thbattle__rinnosuke_qinqu"] = "寝取",
  ["#thbattle__rinnosuke_qinqu-active"] = "寝取：弃置两张手牌并选择一名已受伤的其他角色",
  [":thbattle__rinnosuke_qinqu"] = "出牌阶段限一次，你可以弃置两张手牌并指定一名已受伤的其他角色，你与其各回复1点体力。",
  ["thbattle__rinnosuke_biantai"] = "变态",
  [":thbattle__rinnosuke_biantai"] = "锁定技，当你失去一张装备区里的装备牌时，你摸两张牌。",
  ["$thbattle__rinnosuke_qinqu"] = "你需要爱的守护~",
  ["$thbattle__rinnosuke_biantai"] = "让我们坦然相对吧~",
  ["~thbattle__rinnosuke"] = "还没脱呢！",
}



local thbattle__shikieiki = General:new(extension, "thbattle__shikieiki", "tho", 3, 3, 2)


local thbattle__shikieiki_shenpan = fk.CreateTriggerSkill {
  name = "thbattle__shikieiki_shenpan",
  anim_type = "control",
  events = { fk.AskForRetrial },
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and not player:isNude()
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local card = room:askForResponse(player, self.name, ".",
      "#thbattle__shikieiki_shenpan-ask::" .. target.id .. ":" .. data.reason .. ":" .. data.card:toLogString(),
      false)
    if card then
      room:retrial(card, player, data, self.name, true)
    end
  end,
}



local thbattle__shikieiki_weiyan = fk.CreateTriggerSkill {
  name = "thbattle__shikieiki_weiyan",
  anim_type = "masochism",
  events = { fk.Damaged },
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(self) and data.from and not data.from.dead and data.from ~= player then
      return not data.from:isNude()
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local from = data.from
    local card = room:askForCardChosen(player, from, "he", self.name)
    room:obtainCard(player.id, card, false, fk.ReasonPrey, player.id, self.name)
  end
}

thbattle__shikieiki:addSkill(thbattle__shikieiki_weiyan)
thbattle__shikieiki:addSkill(thbattle__shikieiki_shenpan)

Fk:loadTranslationTable {
  ["thbattle__shikieiki"] = "四季映姬",
  ["#thbattle__shikieiki"] = "胸不平何以平天下",
  ["designer:thbattle__shikieiki"] = "失心",
  ["cv:thbattle__shikieiki"] = "shourei小N",
  ["illustrator:thbattle__shikieiki"] = "和茶",
  ["thbattle__shikieiki_shenpan"] = "审判",
  ["#thbattle__shikieiki_shenpan-ask"] = "审判：打出一张牌替换 %dest 的 %arg 判定牌 %arg2",
  [":thbattle__shikieiki_shenpan"] = "每当一名角色的判定牌生效前，你可以打出一张牌代替之。",
  ["thbattle__shikieiki_weiyan"] = "威严",
  [":thbattle__shikieiki_weiyan"] = "每当你受到一次伤害后，你可以获得伤害来源的一张牌。",
  ["$thbattle__shikieiki_shenpan"] = "有罪！",
  ["$thbattle__shikieiki_weiyan"] = "嗯哼~",
  ["~thbattle__shikieiki"] = "也许，我也该休息一下了。",
}


local thbattle__tewi = General:new(extension, "thbattle__tewi", "tho", 4, 4, 2)

local thbattle__tewi_xingyun = fk.CreateTriggerSkill {
  name = "thbattle__tewi_xingyun",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = { fk.AfterCardsMove },
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return end
    if not player:isKongcheng() then return end
    for _, move in ipairs(data) do
      if move.from == player.id then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerHand then
            return true
          end
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(2, self.name)
  end,
}

thbattle__tewi:addSkill(thbattle__tewi_xingyun)

Fk:loadTranslationTable {
  ["thbattle__tewi"] = "因幡帝",
  ["#thbattle__tewi"] = "幸运的腹黑兔子",
  ["designer:thbattle__tewi"] = "失心",
  ["cv:thbattle__tewi"] = "北斗夜",
  ["illustrator:thbattle__tewi"] = "和茶",
  ["thbattle__tewi_xingyun"] = "幸运",
  [":thbattle__tewi_xingyun"] = "锁定技，每当你失去最后的手牌时，你摸两张牌。",
  ["$thbattle__tewi_xingyun"] = "Lucky！",
  ["~thbattle__tewi"] = "我的好运都跑到哪里去了？",
}


local thbattle__yugi = General(extension, "thbattle__yugi", "tho", 4, 4, 2)

local thbattle__yugi_qiangxi = fk.CreateDistanceSkill {
  name = "thbattle__yugi_qiangxi",
  frequency = Skill.Compulsory,
  correct_func = function(self, from, to)
    if from:hasSkill(self) then
      return -1
    end
  end,
}

local thbattle__yugi_guaili = fk.CreateTriggerSkill {
  name = "thbattle__yugi_guaili",
  anim_type = "offensive",
  events = { fk.TargetSpecified, fk.Damage },
  can_trigger = function(self, event, target, player, data)
    if event == fk.TargetSpecified then
      return target == player and player:hasSkill(self) and data.card and data.card.trueName == "slash"
    elseif event == fk.Damage then
      return target == player and player:hasSkill(self) and data.card and data.card.trueName == "slash"
          and data.to and not data.to.dead and not data.to:isNude() and
          data.card:getMark("thbattle__yugi_guaili") >
          0
    end
  end,
  on_cost = function(self, event, target, player, data)
    if event == fk.TargetSpecified then
      return player.room:askForSkillInvoke(player, self.name)
    end
    return true
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.TargetSpecified then
      local judge = {
        who = player,
        reason = self.name,
        pattern = ".|.|.|.",
      }
      room:judge(judge)
      if judge.card.color == Card.Red then
        data.disresponsive = true
      elseif judge.card.color == Card.Black then
        room:addCardMark(data.card, "thbattle__yugi_guaili")
      end
    elseif event == fk.Damage then
      room:removeCardMark(data.card, "thbattle__yugi_guaili")
      local cards = room:askForCardsChosen(player, data.to, 1, 1, "he", self.name)
      if #cards > 0 then
        room:throwCard(cards, self.name, data.to, player)
      end
    end
  end,
}

thbattle__yugi:addSkill(thbattle__yugi_guaili)
thbattle__yugi:addSkill(thbattle__yugi_qiangxi)
Fk:loadTranslationTable {
  ["thbattle__yugi"] = "星熊勇仪",
  ["#thbattle__yugi"] = "人所谈论的怪力乱神",
  ["designer:thbattle__yugi"] = "失心",
  ["cv:thbattle__yugi"] = "北斗夜",
  ["illustrator:thbattle__yugi"] = "渚FUN",
  ["thbattle__yugi_qiangxi"] = "强袭",
  [":thbattle__yugi_qiangxi"] = "锁定技，你与其他角色计算距离时始终-1。",
  ["thbattle__yugi_guaili"] = "怪力",
  [":thbattle__yugi_guaili"] = "每当你使用弹幕指定了其他角色时，你可以进行一次判定，若结果为红，则此弹幕不能被响应；若结果为黑，则此弹幕造成伤害后，你弃置其一张牌。",
  ["$thbattle__yugi_guaili1"] = "友情破颜拳！",
  ["$thbattle__yugi_guaili2"] = "三步必杀！",
  ["~thbattle__yugi"] = "战得痛快！",
}


-- 宵暗的妖怪 露米娅 体力：3

-- 黑暗：出牌阶段限一次，你可以弃置一张牌并指定一名其他角色，令其选择一项：
-- >> 对其攻击范围内另一名你指定的其他角色使用一张弹幕。
-- >> 受到你造成的1点伤害。

-- 作弊：锁定技，结束阶段开始时，你摸一张牌。

-- （画师：和茶，CV：小羽）

local thbattle__lumiya = General(extension, "thbattle__lumiya", "tho", 3, 3, 2)

local thbattle__lumiya_heian = fk.CreateActiveSkill {
  name = "thbattle__lumiya_heian",
  anim_type = "offensive",
  prompt = "#thbattle__lumiya_heian",
  no_indicate = true,
  target_num = 2,
  target_filter = function(self, to_select, selected, selected_cards, card, extra_data,user)
    if to_select ~= user.id then
      if #selected < 1 then
        return true
      elseif #selected == 1 then
        return Fk:currentRoom():getPlayerById(selected[1]):canUseTo(Fk:cloneCard("slash"),
          Fk:currentRoom():getPlayerById(to_select))
      else
        return false
      end
    end
  end,
  card_num = 1,
  max_phase_use_time = 1,
  card_filter =function (self, to_select, selected, user)
    return #selected < 1 and not user:prohibitDiscard(to_select)
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target1 = room:getPlayerById(effect.tos[1])
    local target2 = room:getPlayerById(effect.tos[2])
    room:doIndicate(effect.from, { effect.tos[1] })
    room:doIndicate(effect.tos[1], { effect.tos[2] })
    -- local usecard = player.room:askForUseCard(player, "slash", nil, "#thbattle__lingmeng_tuizhi:" ..
    --   self.cost_data.id, true,
    --   { bypass_distances = true, must_targets = { self.cost_data.id } })
    local use = player.room:askForUseCard(target1, "slash", nil, "#thbattle__lumiya_heian-use::" .. target2.id, true,
      { must_targets = { target2.id } })
    if use then
      room:useCard(use)
    else
      room:damage({
        from = player,
        damage = 1,
        to = target1,
        skillName = self.name
      })
    end
  end,
}

local thbattle__lumiya_zuobi = fk.CreateTriggerSkill {
  name = "thbattle__lumiya_zuobi",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = { fk.EventPhaseStart },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Finish
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, self.name)
  end,
}

thbattle__lumiya:addSkill(thbattle__lumiya_heian)
thbattle__lumiya:addSkill(thbattle__lumiya_zuobi)

Fk:loadTranslationTable {
  ["thbattle__lumiya"] = "露米娅",
  ["#thbattle__lumiya"] = "宵暗的妖怪",
  ["~thbattle__lumiya"] = "呜啊，你能看见我~",
  ["designer:thbattle__lumiyai"] = "Rem",
  ["cv:thbattle__lumiya"] = "小羽",
  ["illustrator:thbattle__lumiya"] = "和茶",

  ["thbattle__lumiya_heian"] = "黑暗",
  ["#thbattle__lumiya_heian"] = "黑暗:你可以弃置一张牌并指定一名其他角色，令其对你选择的另一名角色使用【弹幕】，或者你对其造成一点伤害",
  ["#thbattle__lumiya_heian-use"] = "黑暗：你需要对【%dest】使用一张【弹幕】，否则你受到1点伤害",
  ["$thbattle__lumiya_heian1"] = "是这样吗？",
  ["$thbattle__lumiya_heian2"] = "关灯啦",
  [":thbattle__lumiya_heian"] = "出牌阶段限一次，你可以弃置一张牌并指定一名其他角色，令其选择一项：" ..
      "<font color='red'>>></font> 对其攻击范围内另一名你指定的其他角色使用一张【弹幕】。" ..
      "<font color='red'>>></font> 受到你造成的1点伤害。",


  ["thbattle__lumiya_zuobi"] = "作弊",
  [":thbattle__lumiya_zuobi"] = "锁定技，结束阶段开始时，你摸一张牌。",
  ["$thbattle__lumiya_zuobi"] = "呀哈哈，露米娅也不知道~",
}


-- 小小的酒鬼夜行 伊吹萃香 体力：4

-- 酒豪：出牌阶段每名角色限一次，你可以和其他角色拼点，若你赢，视为你和其各使用了一张酒，若你没赢，你不能发动此技能，直到回合结束。

-- 醉梦：锁定技，你处于“喝醉”状态时，攻击范围+2；准备阶段开始时，你摸一张牌。

-- （画师：和茶，CV：shourei小N）


local thbattle__cuixiang = General:new(extension, "thbattle__cuixiang", "tho", 4, 4, 2)

local thbattle__cuixiang_jiuhao = fk.CreateActiveSkill {
  name = "thbattle__cuixiang_jiuhao",
  prompt = "#thbattle__cuixiang_jiuhao",
  anim_type = "offensive",
  target_num = 1,
  target_filter = function(self, to_select, selected, selected_cards, card, extra_data,user)
    return #selected < 1 and to_select ~= user.id and not Fk:currentRoom():getPlayerById(to_select):isKongcheng()
        and Fk:currentRoom():getPlayerById(to_select):getMark("thbattle__cuixiang_jiuhao-phase") == 0
  end,
  can_use = function(self, player, card, extra_data)
    return player:getMark("thbattle__cuixiang_jiuhao-turn") == 0 and not player:isKongcheng()
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local pindian_struct = player:pindian({ target }, self.name)
    if pindian_struct.results[target.id].winner == player then
      room:useCard({
        from = player.id,
        tos = { { player.id } },
        card = Fk:cloneCard("jiu"),
      })
      room:useCard({
        from = target.id,
        tos = { { target.id } },
        card = Fk:cloneCard("jiu"),
      })
    else
      room:addPlayerMark(player, "thbattle__cuixiang_jiuhao-turn")
    end
    room:addPlayerMark(target, "thbattle__cuixiang_jiuhao-phase")
  end,
}

local thbattle__cuixiang_zuimeng = fk.CreateAttackRangeSkill {
  name = "thbattle__cuixiang_zuimeng",
  frequency = Skill.Compulsory,
  correct_func = function(self, from, to)
    if from:hasSkill(self) and from:getMark("@@hezui") > 0 then
      return 2
    end
  end,
}

local thbattle__cuixiang_zuimeng_trigger = fk.CreateTriggerSkill {
  name = "#thbattle__cuixiang_zuimeng_trigger",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = { fk.EventPhaseStart },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Start and
        player:getMark("@@hezui") > 0
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, self.name)
  end
}

thbattle__cuixiang_zuimeng:addRelatedSkill(thbattle__cuixiang_zuimeng_trigger)
thbattle__cuixiang:addSkill(thbattle__cuixiang_jiuhao)
thbattle__cuixiang:addSkill(thbattle__cuixiang_zuimeng)

Fk:loadTranslationTable {
  ["thbattle__cuixiang"] = "伊吹萃香",
  ["#thbattle__cuixiang"] = "小小的酒鬼夜行",
  ["~thbattle__cuixiang"] = "我！我还没醉~~",
  ["designer:thbattle__cuixiang"] = "Rem",
  ["cv:thbattle__cuixiang"] = "shourei小N",
  ["illustrator:thbattle__cuixiang"] = "和茶",


  ["thbattle__cuixiang_jiuhao"] = "酒豪",
  ["$thbattle__cuixiang_jiuhao"] = "老板，再来一份醋溜便当下酒！",
  [":thbattle__cuixiang_jiuhao"] = "出牌阶段每名角色限一次，你可以和其他角色拼点，若你赢，视为你和其各使用了一张【酒】，若你没赢，你不能发动此技能，直到回合结束。",
  ["#thbattle__cuixiang_jiuhao"] = "酒豪:你可以和其他角色拼点，若你赢，视为你和其各使用了一张【酒】，若你没赢，你不能发动此技能，直到回合结束。。",


  ["thbattle__cuixiang_zuimeng"] = "醉梦",
  ["$thbattle__cuixiang_zuimeng"] = "今天~要喝个痛快~",
  [":thbattle__cuixiang_zuimeng"] = "锁定技，你处于“喝醉”状态时，攻击范围+2；准备阶段开始时，你摸一张牌。",
  ["#thbattle__cuixiang_zuimeng_trigger"] = "醉梦",
}



-- 有顶天的大M子 比那名居天子 体力：3

-- 抖Ｍ：每当你受到1点伤害后，你可以观看牌堆顶的两张牌，并将这些牌交给至少一名角色。

-- 绯想：锁定技，距离1以内的角色的红色判定牌生效后，你获得之。

-- （画师：月见，CV：VV）

local thbattle__tianzi = General:new(extension, "thbattle__tianzi", "tho", 3, 3, 2)

local thbattle__tianzi_doum = fk.CreateTriggerSkill {
  name = "thbattle__tianzi_doum",
  anim_type = "masochism",
  prompt = "#thbattle__tianzi_doum-active",
  events = { fk.Damaged },
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = room:getNCards(2 * data.damage)
    room:obtainCard(player, cards, false, fk.ReasonPrey, player.id, self.name)
    THB_Utility.askForDistribution(player, cards, room.alive_players, self.name, 0, #cards,
      "#thbattle__tianzi_doum_shareCards")
  end
}

local thbattle__tianzi_feitian = fk.CreateTriggerSkill {
  name = "thbattle__tianzi_feitian",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = { fk.FinishJudge },
  can_trigger = function(self, event, target, player, data)
    return data.card.color == Card.Red and player:hasSkill(self) and
        player.room:getCardArea(data.card) == Card.Processing and
        (data.who == player or player:distanceTo(data.who) == 1)
  end,
  on_use = function(self, event, target, player, data)
    player.room:obtainCard(player.id, data.card, true, fk.ReasonJustMove)
  end
}


thbattle__tianzi:addSkill(thbattle__tianzi_doum)
thbattle__tianzi:addSkill(thbattle__tianzi_feitian)

Fk:loadTranslationTable {
  ["thbattle__tianzi"] = "比那名居天子",
  ["#thbattle__tianzi"] = "有顶天的大M子",
  ["designer:thbattle__tianzi"] = "Rem",
  ["~thbattle__tianzi"] = "啊~~~呜————T^T",
  ["cv:thbattle__tianzi"] = "VV",
  ["illustrator:thbattle__cuixiang"] = "月见",


  ["thbattle__tianzi_doum"] = "抖M",
  ["$thbattle__tianzi_doum"] = "kimoji<font color='red'>♥</font>~",
  [":thbattle__tianzi_doum"] = "每当你受到1点伤害后，你可以观看牌堆顶的两张牌，并将这些牌交给至少一名角色。",
  ["#thbattle__tianzi_doum-active"] = "你是否发动【抖M】",
  ["#thbattle__tianzi_doum_shareCards"] = "抖M：你可以将这些牌分配给其他角色，或点“取消”自己保留",

  ["thbattle__tianzi_feitian"] = "绯想",
  ["$thbattle__tianzi_feitian"] = "拿过来吧！",
  [":thbattle__tianzi_feitian"] = "锁定技，距离1以内的角色的红色判定牌生效后，你获得之。",
}


-- 半分虚幻的厨师 魂魄妖梦 体力：4

-- 迷津慈航斩：锁定技，你使用的弹幕需要连续使用两张擦弹来抵消；与你进行弹幕战的角色每次需要连续打出两张弹幕。

-- 二刀流：你可以额外装备一把武器，当你同时装备了两把武器时，攻击范围按其中较高者计算；武器技能同时有效，且你额外增加一点干劲。
-- >> 当你受到人形操控的效果生效时，需交出全部的武器。

-- （画师：霏茶，CV：小羽）

local thbattle__yaomeng = General:new(extension, "thbattle__yaomeng", "tho", 4, 4, 2)

local thbattle__yaomeng_erdaoliu = fk.CreateTriggerSkill {
  name = "thbattle__yaomeng_erdaoliu",
  frequency = Skill.Compulsory,
  events = { fk.GameStart },
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:addPlayerEquipSlots(player, { Player.WeaponSlot })
  end,
}

local thbattle__yaomeng_erdaoliu_extra = fk.CreateTargetModSkill {
  name = "#thbattle__yaomeng_erdaoliu_extra",
  frequency = Skill.Compulsory,
  residue_func = function(self, player, skill, scope, card, to)
    if card and player:hasSkill(thbattle__yaomeng_erdaoliu) and card.trueName == "slash" and #player:getCardIds("e") > 0
        and #table.filter(player:getCardIds("e"), function(cid)
          return Fk:getCardById(cid).sub_type == Card.SubtypeWeapon
        end) == 2 then
      return 1
    end
  end,
}
local thbattle__yaomeng_erdaoliu_Audio = fk.CreateTriggerSkill {
  name = "#thbattle__yaomeng_erdaoliu_Audio",
  visible = false,
  refresh_events = { fk.CardUsing },
  can_refresh = function(self, event, target, player, data)
    local targets = TargetGroup:getRealTargets(data.tos)
    local to = player.room:getPlayerById(targets[1])
    return target == player and player:hasSkill(self) and
        data.card.trueName == "slash" and player:compareDistance(to, 1, ">") and
        player:usedCardTimes("slash") > 1
  end,
  on_refresh = function(self, event, target, player, data)
    player:broadcastSkillInvoke("thbattle__yaomeng_erdaoliu")
    player.room:doAnimate("InvokeSkill", {
      name = "thbattle__yaomeng_erdaoliu",
      player = player.id,
      skill_type = "offensive",
    })
  end,
}

local thbattle__yaomeng_cijing = fk.CreateTriggerSkill {
  name = "thbattle__yaomeng_cijing",
  anim_type = "offensive",
  frequency = Skill.Compulsory,
  events = { fk.TargetSpecified, fk.TargetConfirmed },
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then
      return false
    end
    if event == fk.TargetSpecified then
      return target == player and table.contains({ "slash", "duel" }, data.card.trueName)
    else
      return data.to == player.id and data.card.trueName == "duel"
    end
  end,
  on_use = function(self, event, target, player, data)
    data.fixedResponseTimes = data.fixedResponseTimes or {}
    if data.card.trueName == "slash" then
      data.fixedResponseTimes["jink"] = 2
    else
      data.fixedResponseTimes["slash"] = 2
      data.fixedAddTimesResponsors = data.fixedAddTimesResponsors or {}
      table.insert(data.fixedAddTimesResponsors, (event == fk.TargetSpecified and data.to or data.from))
    end
  end,
}


thbattle__yaomeng_erdaoliu:addRelatedSkill(thbattle__yaomeng_erdaoliu_extra)

thbattle__yaomeng_erdaoliu:addRelatedSkill(thbattle__yaomeng_erdaoliu_Audio)
thbattle__yaomeng:addSkill(thbattle__yaomeng_erdaoliu)
thbattle__yaomeng:addSkill(thbattle__yaomeng_cijing)
Fk:loadTranslationTable {
  ["thbattle__yaomeng"] = "魂魄妖梦",
  ["#thbattle__yaomeng"] = "半分虚幻的厨师",
  ["~thbattle__yaomeng"] = "啊啦，该给幽幽子大人做饭了————",
  ["designer:thbattle__yaomeng"] = "Rem",
  ["cv:thbattle__yaomeng"] = "小羽",
  ["illustrator:thbattle__yaomeng"] = "霏茶",

  ["thbattle__yaomeng_erdaoliu"] = "二刀",
  ["$thbattle__yaomeng_erdaoliu"] = "我还是有两把刷子的。",
  [":thbattle__yaomeng_erdaoliu"] = "你可以额外装备一把武器，当你同时装备了两把武器时，攻击范围按其中较高者计算；武器技能同时有效，且你额外增加一点干劲。"
      .. "<font color='red'>>></font> 当你受到人形操控的效果生效时，需交出全部的武器。",

  ["thbattle__yaomeng_cijing"] = "迷津慈航斩",
  ["$thbattle__yaomeng_cijing"] = "先斩了再说！",
  [":thbattle__yaomeng_cijing"] = "锁定技，你使用的弹幕需要连续使用两张擦弹来抵消；与你进行弹幕战的角色每次需要连续打出两张弹幕。",
}


-- 永远17岁 八云紫 体力：4

-- 神隐：出牌阶段限两次，你可以将场上的一张牌暂时移出游戏。你可以观看以此法移出游戏的牌。
--   任何角色被紫暂时移出的牌，会在紫的结束阶段后归还回该角色的手牌中。

-- （画师：Vivicat@幻想梦斗符，CV：VV）

local thbattle__bayunzi = General:new(extension, "thbattle__bayunzi", "tho", 4, 4, 2)

local thbattle__bayunzi_shenyin = fk.CreateActiveSkill {
  name = "thbattle__bayunzi_shenyin",
  prompt = "#thbattle__bayunzi_shenyin",
  anim_type = "control",
  target_num = 1,
  target_filter = function(self, to_select, selected, selected_cards, card, extra_data,user)
    return #selected < 1 and #Fk:currentRoom():getPlayerById(to_select):getCardIds("hej") > 0
  end,
  max_phase_use_time = 2,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local card = room:askForCardChosen(player, target, "hej", self.name, "#thbattle__bayunzi_shenyin-choose_card")
    target:addToPile("thbattle__bayunzi_shenyin", card, false, self.name, player.id, { player.id, target.id })
  end,
}

local thbattle__bayunzi_shenyin_back = fk.CreateTriggerSkill {
  name = "#thbattle__bayunzi_shenyin_back",
  mute = true,
  global = true,
  frequency = Skill.Compulsory,
  refresh_events = { fk.EventPhaseEnd },
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Finish
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    for _, p in ipairs(room.alive_players) do
      if #p:getPile("thbattle__bayunzi_shenyin") > 0 then
        room:moveCardTo(p:getPile("thbattle__bayunzi_shenyin"), Card.PlayerHand, p, fk.ReasonJustMove,
          "thbattle__bayunzi_shenyin")
      end
    end
  end
}

thbattle__bayunzi_shenyin:addRelatedSkill(thbattle__bayunzi_shenyin_back)
thbattle__bayunzi:addSkill(thbattle__bayunzi_shenyin)


Fk:loadTranslationTable {
  ["thbattle__bayunzi"] = "八云紫",
  ["#thbattle__bayunzi"] = "永远17岁",
  ["~thbattle__bayunzi"] = "哎哟，我的腰呀~~",
  ["designer:thbattle__bayunzi"] = "Rem",
  ["cv:thbattle__bayunzi"] = "VV",
  ["illustrator:thbattle__bayunzi"] = "Vivicat@幻想梦斗符",

  ["thbattle__bayunzi_shenyin"] = "神隐",
  ["$thbattle__bayunzi_shenyin1"] = "十七岁就是十七岁！",
  ["$thbattle__bayunzi_shenyin2"] = "叫紫妹就对了，紫妈算什么！",
  [":thbattle__bayunzi_shenyin"] = "出牌阶段限两次，你可以将场上的一张牌暂时移出游戏。你可以观看以此法移出游戏的牌。" ..
      "任何角色被紫暂时移出的牌，会在紫的结束阶段后归还回该角色的手牌中。",
  ["#thbattle__bayunzi_shenyin"] = "神隐:你可以将场上的一张牌暂时移出游戏。你可以观看以此法移出游戏的牌。",
  ["#thbattle__bayunzi_shenyin-choose_card"] = "神隐:你可以将场上的一张牌暂时移出游戏。你可以观看以此法移出游戏的牌。",

}

-- 四季的鲜花之主 风见幽香 体力：4

-- 逆鳞：每当你成为其他角色使用的单体符卡效果目标时，你可以将其视为弹幕战效果；你的回合外，你可以将一张手牌当做弹幕使用或打出。

-- 施虐：当你击坠一名角色时，你可以对攻击范围内一名其他角色造成1点伤害；你对体力值为1的其他角色造成的伤害+1。

local thbattle__youxiang = General:new(extension, "thbattle__youxiang", "tho", 4, 4, 2)

local thbattle__youxiang_nilin = fk.CreateViewAsSkill {
  name = "thbattle__youxiang_nilin",
  mute = true,
  prompt = "#thbattle__youxiang_nilin",
  pattern = "slash",
  card_filter =function (self, to_select, selected, player)
    return #selected < 1 and Fk:currentRoom():getCardArea(to_select) == Player.Hand
  end,
  view_as = function(self, cards,user)
    if #cards ~= 1 then
      return nil
    end
    local c = Fk:cloneCard("danmu__slash")
    c.skillName = self.name
    c:addSubcard(cards[1])
    return c
  end,
  before_use = function(self, player, use)
    player.room:broadcastPlaySound(Thbattle_path .. "audio/skill/thbattle__youxiang_nilin1")
    player.room:notifySkillInvoked(player, self.name, "defensive")
    return
  end,
  enabled_at_play = function(self, player)
    return player.phase == Player.NotActive
  end,
  enabled_at_response = function(self, player)
    return player.phase == Player.NotActive
  end,
}

local thbattle__youxiang_nilin_trigger = fk.CreateTriggerSkill {
  name = "#thbattle__youxiang_nilin_trigger",
  prompt = "#thbattle__youxiang_nilin_trigger-prompt",
  events = { fk.TargetConfirming },
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(thbattle__youxiang_nilin) and data.card and data.from ~= player.id and
        data.card:isCommonTrick() and data.card.multiple_targets ~= true and data.card.skillName ~= self.name
  end,
  on_use = function(self, event, target, player, data)
    player:broadcastSkillInvoke("thbattle__youxiang_nilin", 2)
    player.room:notifySkillInvoked(player, self.name, "masochism")
    table.insert(data.nullifiedTargets, player.id)
    AimGroup:cancelTarget(data, player.id)
    local card = Fk:cloneCard("danmuzhan__duel", data.card.suit, data.card.number)
    card.skillName = self.name
    player.room:useCard({
      from = data.from,
      tos = { { player.id } },
      card = card
    })
  end
}

local thbattle__youxiang_shinv = fk.CreateTriggerSkill {
  name = "thbattle__youxiang_shinv",
  anim_type = "offensive",
  prompt = "#thbattle__youxiang_nilin_shinv",
  events = { fk.Death },
  can_trigger = function(self, event, target, player, data)
    return target ~= player and player:hasSkill(self) and data.damage and data.damage.from and
        data.damage.from == player
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targetplayer = room:askForChoosePlayers(player,
      table.map(table.filter(room:getOtherPlayers(player), function(p)
        return player:inMyAttackRange(p)
      end), Util.IdMapper), 1, 1, "#thbattle__youxiang_nilin_shinv-choose_player", self.name, true)
    if #targetplayer > 0 then
      room:damage({
        from = player,
        to = room:getPlayerById(targetplayer[1]),
        damage = 1,
        skillName = self.name
      })
    end
  end
}

local thbattle__youxiang_shinv_damage = fk.CreateTriggerSkill {
  name = "#thbattle__youxiang_shinv_damage",
  anim_type = "offensive",
  prompt = "#thbattle__youxiang_nilin_shinv_damage-prompt",
  events = { fk.DamageCaused },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.to.hp == 1
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    data.damage = (data.damage or 0) + 1
  end
}


thbattle__youxiang_shinv:addRelatedSkill(thbattle__youxiang_shinv_damage)
thbattle__youxiang_nilin:addRelatedSkill(thbattle__youxiang_nilin_trigger)
thbattle__youxiang:addSkill(thbattle__youxiang_nilin)
thbattle__youxiang:addSkill(thbattle__youxiang_shinv)

Fk:loadTranslationTable {
  ["thbattle__youxiang"] = "风见幽香",
  ["#thbattle__youxiang"] = "四季的鲜花之主",
  ["~thbattle__youxiang"] = "呃..居然败在你们的手下..",
  ["designer:thbattle__youxiang"] = "Rem",
  ["cv:thbattle__youxiang"] = "VV",
  ["illustrator:thbattle__youxiang"] = "霏茶",

  ["thbattle__youxiang_nilin"] = "逆鳞",
  ["$thbattle__youxiang_nilin1"] = "哼！",
  ["$thbattle__youxiang_nilin2"] = "正面上我呀！",
  [":thbattle__youxiang_nilin"] = "每当你成为其他角色使用的单体符卡效果目标时，你可以将其视为【弹幕战】效果；你的回合外，你可以将一张手牌当做【弹幕】使用或打出。",
  ["#thbattle__youxiang_nilin"] = "逆鳞:你可以将一张手牌当做【弹幕】使用或打出。",
  ["#thbattle__youxiang_nilin_trigger"] = "逆鳞",
  ["#thbattle__youxiang_nilin_trigger-prompt"] = "逆鳞:每当你成为其他角色使用的单体符卡效果目标时，你可以将其视为【弹幕战】效果",

  ["thbattle__youxiang_shinv"] = "施虐",
  ["$thbattle__youxiang_shinv"] = "额哈哈哈，还有谁想试试？",
  [":thbattle__youxiang_shinv"] = "当你击坠一名角色时，你可以对攻击范围内一名其他角色造成1点伤害；你对体力值为1的其他角色造成的伤害+1。",
  ["#thbattle__youxiang_shinv"] = "施虐:当你击坠一名角色时，你可以对攻击范围内一名其他角色造成1点伤害",
  ["#thbattle__youxiang_nilin_shinv-choose_player"] = "施虐:你可以对攻击范围内一名其他角色造成1点伤害",
  ["#thbattle__youxiang_shinv_damage"] = "施虐",
  ["#thbattle__youxiang_shinv_damage-prompt"] = "施虐:你对体力值为1的其他角色造成的伤害+1。",

}



-- FFF团资深团员 藤原妹红 体力：4

-- 重生：准备阶段开始时，你可以弃置X张红色牌，然后回复1点体力。（X为你的体力值）

-- 浴火：结束阶段开始时，你可以失去1点体力，然后摸两张牌。

-- （画师：六仔OwO，CV：小羽）


local thbattle__meihong = General:new(extension, "thbattle__meihong", "tho", 4, 4, 2)

local thbattle__meihong_chongsheng = fk.CreateTriggerSkill {
  name = "thbattle__meihong_chongsheng",
  prompt = "#thbattle__meihong_chongsheng",
  anim_type = "support",
  events = { fk.EventPhaseStart },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Start
  end,
  on_cost = function(self, event, target, player, data)
    if player.room:askForSkillInvoke(player, self.name) then
      local cards = player.room:askForDiscard(player, player.hp, player.hp, true, self.name, true,
        ".|.|heart,diamond"
        , "#thbattle__meihong_chongsheng-discard:::" .. player.hp)
      if #cards > 0 then
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:recover({
      who = player,
      num = 1,
      skillName = self.name
    })
  end
}

local thbattle__meihong_yuhuo = fk.CreateTriggerSkill {
  name = "thbattle__meihong_yuhuo",
  prompt = "#thbattle__meihong_yuhuo",
  anim_type = "drawcard",
  events = { fk.EventPhaseStart },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Finish
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:loseHp(player, 1, self.name)
    player:drawCards(2, self.name)
  end
}


thbattle__meihong:addSkill(thbattle__meihong_chongsheng)
thbattle__meihong:addSkill(thbattle__meihong_yuhuo)
Fk:loadTranslationTable {
  ["thbattle__meihong"] = "藤原妹红",
  ["#thbattle__meihong"] = "FFF团资深团员",
  ["~thbattle__meihong"] = "今天就到这里吧",
  ["designer:thbattle__meihong"] = "Rem",
  ["cv:thbattle__meihong"] = "小羽",
  ["illustrator:thbattle__meihong"] = "六仔OwO",

  ["thbattle__meihong_chongsheng"] = "重生",
  ["$thbattle__meihong_chongsheng"] = "真是方便的能力呢",
  [":thbattle__meihong_chongsheng"] = "准备阶段开始时，你可以弃置X张红色牌，然后回复1点体力。（X为你的体力值）",
  ["#thbattle__meihong_chongsheng"] = "重生:你可以弃置X张红色牌，然后回复1点体力。（X为你的体力值）",
  ["#thbattle__meihong_chongsheng-discard"] = "重生:你可以弃置%arg张红色牌，然后回复1点体力。",

  ["thbattle__meihong_yuhuo"] = "浴火",
  ["$thbattle__meihong_yuhuo"] = "不可饶恕！",
  [":thbattle__meihong_yuhuo"] = "结束阶段开始时，你可以失去1点体力，然后摸两张牌。",
  ["#thbattle__meihong_yuhuo"] = "浴火:你可以失去1点体力，然后摸两张牌。",
}


-- 表情丰富的扑克脸 秦心 体力：3

-- 希望之面：出牌阶段开始时，你可以观看牌堆顶的1+X张牌，然后展示并获得其中任意数量的同花色牌，其余的牌以任意顺序置于牌堆顶。（X为你已损失的体力值）

-- 暗黑能乐：出牌阶段限一次，你可以将一张黑色牌置于体力值不小于你的其他角色的明牌区，然后其须弃置除获得的牌以外的手牌，直到手牌数与体力值相等。

-- （画师：Takibi，CV：小羽/VV）
local thbattle__qinxin = General:new(extension, "thbattle__qinxin", "tho", 3, 3, 2)

Fk:addPoxiMethod {
  name = "thbattle__qinxin_xiwang_getcards",
  card_filter = function(to_select, selected, data)
    if #data[2] == 0 then
      return true
    else
      local suit = Fk:getCardById(data[2][1]).suit
      return Fk:getCardById(to_select).suit == suit
    end
  end,
  feasible = function(selected)
    return true
  end,
}


local thbattle__qinxin_xiwang = fk.CreateTriggerSkill {
  name = "thbattle__qinxin_xiwang",
  prompt = "#thbattle__qinxin_xiwang",
  anim_type = "drawcard",
  events = { fk.EventPhaseStart },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Play
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = room:getNCards(1 + player.maxHp - player.hp)
    local array_cards = room:askForArrangeCards(player, self.name, { cards, "Top", "toObtain" }
      , "#thbattle__qinxin_xiwang-arrange:::" .. #cards, true, nil,
      { 1 + player.maxHp - player.hp, 1 + player.maxHp - player.hp },
      { 0, 0 }, ".", "thbattle__qinxin_xiwang_getcards"
      , { {}, { cards[1] } })
    room:showCards(array_cards[2])
    room:obtainCard(player, array_cards[2], false, fk.ReasonPrey, player.id, self.name)
    if #array_cards[1] > 0 then
      for i, cid in ipairs(array_cards[1]) do
        table.remove(room.draw_pile, i)
        table.insert(room.draw_pile, i, cid)
      end
    end
  end
}

local thbattle__qinxin_anhei = fk.CreateActiveSkill {
  name = "thbattle__qinxin_anhei",
  prompt = "#thbattle__qinxin_anhei",
  anim_type = "control",
  card_num = 1,
  card_filter =function (self, to_select, selected, user)
    return #selected < 1 and Fk:getCardById(to_select).color == Card.Black
  end,
  target_num = 1,
  target_filter = function(self, to_select, selected, selected_cards, card, extra_data,user)
    return #selected < 1 and to_select ~= user.id and Fk:currentRoom():getPlayerById(to_select).hp >= user.hp
  end,
  max_phase_use_time = 1,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target_id = room:getPlayerById(effect.tos[1])
    local target_card = effect.cards[1]
    if #target_id:getCardIds("h") >= target_id.hp then
      local n = #target_id:getCardIds("h") - target_id.hp + 1
      local cards = room:askForCardsChosen(target_id, target_id, n, n, "h", self.name,
        "#thbattle__qinxin_anhei-discard:::" .. n)
      room:moveCards({
        ids = cards,
        toArea = Card.DiscardPile,
        moveReason = fk.ReasonDiscard,
        proposer = player.id,
        skillName = self.name,
        moveVisible = true,
      })
    end
    room:obtainCard(target_id, target_card, true, fk.ReasonGive, player.id, self.name, "@@thb_mingpai")
  end,
}


thbattle__qinxin:addSkill(thbattle__qinxin_xiwang)
thbattle__qinxin:addSkill(thbattle__qinxin_anhei)

Fk:loadTranslationTable {
  ["thbattle__qinxin"] = "秦心",
  ["#thbattle__qinxin"] = "表情丰富的扑克脸",
  ["~thbattle__qinxin"] = "请允许我换一个悲伤的面具",
  ["designer:thbattle__qinxin"] = "Rem",
  ["cv:thbattle__qinxin"] = "小羽/VV",
  ["illustrator:thbattle__qinxin"] = "Takibi",

  ["thbattle__qinxin_xiwang"] = "希望之面",
  ["$thbattle__qinxin_xiwang"] = "我的希望之面不见了",
  [":thbattle__qinxin_xiwang"] = "出牌阶段开始时，你可以观看牌堆顶的1+X张牌，然后展示并获得其中任意数量的同花色牌，其余的牌以任意顺序置于牌堆顶。（X为你已损失的体力值）",
  ["#thbattle__qinxin_xiwang"] = "希望之面:你可以观看牌堆顶的1+X张牌，然后展示并获得其中任意数量的同花色牌，其余的牌以任意顺序置于牌堆顶。",
  ["#thbattle__qinxin_xiwang-arrange"] = "希望之面:你可以观看牌堆顶的%arg张牌，然后展示并获得其中任意数量的同花色牌，其余的牌以任意顺序置于牌堆顶。",
  ["thbattle__qinxin_xiwang_getcards"] = "希望之面",

  ["thbattle__qinxin_anhei"] = "暗黑能乐",
  ["$thbattle__qinxin_anhei"] = "把全部的感情，都爆发出来吧",
  [":thbattle__qinxin_anhei"] = "出牌阶段限一次，你可以将一张黑色牌置于体力值不小于你的其他角色的明牌区，然后其须弃置除获得的牌以外的手牌，直到手牌数与体力值相等。",
  ["#thbattle__qinxin_anhei"] = "暗黑能乐:你可以将一张黑色牌置于体力值不小于你的其他角色的明牌区，然后其须弃置除获得的牌以外的手牌，直到手牌数与体力值相等。",
  ["#thbattle__qinxin_anhei-discard"] = "暗黑能乐:你需要弃置%arg张牌",
}


-- 大狸子 二岩猯藏 体力：4

-- 变化：出牌阶段限一次，你可以将两张手牌当任意基本牌或非延时符卡使用，这两张牌中至少有一张须与你声明使用的牌类型相同。

-- KOF模式不可用

-- （画师：hacko.@星の妄想乡，CV：shourei小N，人物设计：鵺子丶爱丽丝）

local thbattle__tuanzang = General:new(extension, "thbattle__tuanzang", "tho", 4, 4, 2)

local thbattle__tuanzang_bianhua = fk.CreateViewAsSkill {
  name = "thbattle__tuanzang_bianhua",
  prompt = "#thbattle__tuanzang_bianhua",
  anim_type = "special",
  pattern = ".",
  interaction = function()
    local all_names = U.getAllCardNames("bt")

    local names = {}
    for _, name in ipairs(all_names) do
      local card = Fk:cloneCard(name)
      if not card.is_derived and Fk.currentResponsePattern == nil and card.skill:canUse(Self, card) then
        table.insertIfNeed(names, card.name)
      end
    end
    if #names == 0 then return end
    return UI.ComboBox { choices = names }
  end,
  card_num = 2,
  card_filter =function (self, to_select, selected, player)
    if Fk:currentRoom():getCardArea(to_select) == Card.PlayerHand then
      if #selected == 0 then
        return true
      elseif #selected == 1 then
        local selected_1 = Fk:getCardById(selected[1])
        local interaction_card = Fk:cloneCard(self.interaction.data)
        if selected_1.type == interaction_card.type then
          return true
        else
          return Fk:getCardById(to_select).type == interaction_card.type
        end
      else
        return false
      end
    end
  end,
  view_as = function(self, cards,user)
    if not self.interaction.data then return end
    if #cards ~= 2 then return end
    local card = Fk:cloneCard(self.interaction.data)
    card:addSubcards(cards)
    card.skillName = self.name
    return card
  end,
  enabled_at_play = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 and #player:getCardIds("h") > 1
  end,
  enabled_at_response = function(self, player, response)
    return false
  end
}

thbattle__tuanzang:addSkill(thbattle__tuanzang_bianhua)

Fk:loadTranslationTable {
  ["thbattle__tuanzang"] = "二岩猯藏",
  ["#thbattle__tuanzang"] = "大狸子",
  ["~thbattle__tuanzang"] = "别打了..给..给你干脆面~",
  ["designer:thbattle__tuanzang"] = "Rem",
  ["cv:thbattle__tuanzang"] = "shourei小N",
  ["illustrator:thbattle__tuanzang"] = "hacko.@星の妄想乡",

  ["thbattle__tuanzang_bianhua"] = "变化",
  ["$thbattle__tuanzang_bianhua"] = "超级~变变变！！",
  [":thbattle__tuanzang_bianhua"] = "出牌阶段限一次，你可以将两张手牌当任意基本牌或非延时符卡使用(<a href='thbattle__tuanzang_bianhua-cards'><font color='red'>非响应卡牌</font></a>)，这两张牌中至少有一张须与你声明使用的牌类型相同。",
  ["thbattle__tuanzang_bianhua-cards"] = "非响应卡牌：此牌无法因其他事件主动使用或打出，例如闪，濒死时的酒桃，无懈，因借刀询问的杀，南蛮要求响应的杀。<br/>" ..
      "仅仅是出牌阶段空闲时机可主动使用的卡牌",
  ["#thbattle__tuanzang_bianhua"] = "变化:你可以将两张手牌当任意基本牌或非延时符卡使用，这两张牌中至少有一张须与你声明使用的牌类型相同。",
}


-- 逆袭的天邪鬼 鬼人正邪 体力：3

-- 挑拨：出牌阶段限一次，你可以与一名其他角色拼点，若你赢，视为该角色对其攻击范围内你指定的另一名其他角色使用了一张弹幕；若你没赢，该角色可以视为对你使用了一张弹幕。

-- 逆转：当你受到一名其他角色使用的弹幕效果时，你可以摸一张牌，然后若你的手牌数大于其手牌数，取消该弹幕效果，并视为该角色再对你使用一张弹幕战。

-- KOF模式不可用

-- （画师：霏茶，CV：北斗夜）


local thbattle__zhengxie = General:new(extension, "thbattle__zhengxie", "tho", 3, 3, 2)


local thbattle__zhengxie_tiaobo = fk.CreateActiveSkill {
  name = "thbattle__zhengxie_tiaobo",
  anim_type = "offensive",
  prompt = "#thbattle__zhengxie_tiaobo",
  no_indicate = true,
  target_num = 2,
  target_filter = function(self, to_select, selected, selected_cards, card, extra_data,user)
    if to_select ~= user.id then
      if #selected < 1 then
        return true
      elseif #selected == 1 then
        return Fk:currentRoom():getPlayerById(selected[1]):canUseTo(Fk:cloneCard("slash"),
          Fk:currentRoom():getPlayerById(to_select))
      else
        return false
      end
    end
  end,
  can_use = function(self, player, card, extra_data)
    return not player:isKongcheng() and player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target1 = room:getPlayerById(effect.tos[1])
    local target2 = room:getPlayerById(effect.tos[2])
    room:doIndicate(effect.from, { effect.tos[1] })
    room:doIndicate(effect.tos[1], { effect.tos[2] })
    local pindian_data = player:pindian({ target1 }, self.name)
    if pindian_data.results[target1.id].winner == player then
      room:useCard({
        from = target1.id,
        tos = { { target2.id } },
        card = Fk:cloneCard("danmu__slash"),
      })
    else
      local choice = room:askForChoice(target1, { "#thbattle__zhengxie_tiaobo-slash:" .. player.id, "cancel" },
        self.name)
      if choice ~= "cancel" then
        room:useCard({
          from = target1.id,
          tos = { { player.id } },
          card = Fk:cloneCard("danmu__slash"),
        })
      end
    end
  end,
}
local thbattle__zhengxie_nizhuan = fk.CreateTriggerSkill {
  name = "thbattle__zhengxie_nizhuan",
  prompt = "#thbattle__zhengxie_nizhuan",
  anim_type = "masochism",
  events = { fk.TargetConfirming },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card and data.card.from ~= player.id and
        data.card.trueName == "slash"
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local useplayer = room:getPlayerById(data.from)
    player:drawCards(1, self.name)
    if #player:getCardIds("h") > #useplayer:getCardIds("h") then
      table.insert(data.nullifiedTargets, player.id)
      AimGroup:cancelTarget(data, player.id)
      room:useCard({
        from = useplayer.id,
        tos = { { player.id } },
        card = Fk:cloneCard("danmuzhan__duel"),
      })
    end
  end
}




thbattle__zhengxie:addSkill(thbattle__zhengxie_tiaobo)
thbattle__zhengxie:addSkill(thbattle__zhengxie_nizhuan)

Fk:loadTranslationTable {
  ["thbattle__zhengxie"] = "鬼人正邪",
  ["#thbattle__zhengxie"] = "逆袭的天邪鬼",
  ["~thbattle__zhengxie"] = "弱者难道只能被强者支配吗...",
  ["designer:thbattle__zhengxie"] = "Rem",
  ["cv:thbattle__zhengxie"] = "北斗夜",
  ["illustrator:thbattle__zhengxie"] = "霏茶",

  ["thbattle__zhengxie_tiaobo"] = "挑拨",
  ["$thbattle__zhengxie_tiaobo1"] = "今天去看哪一只少女的胖次呢~",
  ["$thbattle__zhengxie_tiaobo2"] = "悄悄跟你说一件事哦~",
  [":thbattle__zhengxie_tiaobo"] = "出牌阶段限一次，你可以与一名其他角色拼点，若你赢，视为该角色对其攻击范围内你指定的另一名其他角色使用了一张【弹幕】；若你没赢，该角色可以视为对你使用了一张【弹幕】。",
  ["#thbattle__zhengxie_tiaobo"] = "挑拨:你可以与一名其他角色拼点，若你赢，视为该角色对其攻击范围内你指定的另一名其他角色使用了一张【弹幕】；若你没赢，该角色可以视为对你使用了一张【弹幕】。",
  ["#thbattle__zhengxie_tiaobo-slash"] = "挑拨:视为对【%src】使用一张【弹幕】",

  ["thbattle__zhengxie_nizhuan"] = "逆转",
  ["$thbattle__zhengxie_nizhuan"] = "给我翻过来！",
  [":thbattle__zhengxie_nizhuan"] = "当你受到一名其他角色使用的【弹幕】效果时，你可以摸一张牌，然后若你的手牌数大于其手牌数，取消该【弹幕】效果，并视为该角色再对你使用一张【弹幕战】。",
  ["#thbattle__zhengxie_nizhuan"] = "逆转:你可以摸一张牌，然后若你的手牌数大于其手牌数，取消该【弹幕】效果，并视为该角色再对你使用一张【弹幕战】。",
}


-- 山丘与湖泊的化身 八坂神奈子 体力：4

-- 神德：摸牌阶段，你可以放弃摸牌，改为令一名其他角色摸两张牌，然后其须展示并交给你一张牌，若交给你的牌为红桃牌，你摸一张牌。

-- 信仰：限定技，出牌阶段，你可以令你攻击范围内的所有其他角色依次选择一项：
-- >> 令你摸一张牌。
-- >> 弃置你一张牌，然后你视为对其使用了一张弹幕或弹幕战（按此法使用的弹幕不消耗干劲）。

-- KOF模式不可用

-- （画师：和茶，CV：北斗夜/VV）

local thbattle__shennaizi = General:new(extension, "thbattle__shennaizi", "tho", 4, 4, 2)


local thbattle__shennaizi_shende = fk.CreateTriggerSkill {
  name = "thbattle__shennaizi_shende",
  prompt = "#thbattle__shennaizi_shende",
  anim_type = "drawcard",
  events = { fk.DrawNCards },
  on_use = function(self, event, target, player, data)
    local room = player.room
    data.n = 0
    local useplayer = room:askForChoosePlayers(player, table.map(room:getOtherPlayers(player), Util.IdMapper), 1, 1,
      "#thbattle__shennaizi_shende-draw",
      self.name, false)
    local targetPlayer = room:getPlayerById(useplayer[1])
    targetPlayer:drawCards(2, self.name)
    local target_card = room:askForCard(targetPlayer, 1, 1, true, self.name, false, ".",
      "#thbattle__shennaizi_shende-give:" .. player.id)[1]
    targetPlayer:showCards(target_card)
    room:obtainCard(player, target_card, true, fk.ReasonGive, targetPlayer.id, self.name)
    if Fk:getCardById(target_card).suit == Card.Heart then
      player:drawCards(1, self.name)
    end
  end
}

local thbattle__shennaizi_xinyang = fk.CreateActiveSkill {
  name = "thbattle__shennaizi_xinyang",
  anim_type = "big",
  frequency = Skill.Limited,
  prompt = "#thbattle__shennaizi_xinyang",
  can_use = function(self, player, card, extra_data)
    local room = Fk:currentRoom()
    return #table.filter(room.alive_players, function(p)
      return player:inMyAttackRange(p)
    end) > 0 and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local targetplayers = table.filter(room:getOtherPlayers(player), function(p)
      return player:inMyAttackRange(p)
    end)
    for _, p1 in ipairs(targetplayers) do
      room:doIndicate(player.id, { p1.id })
      if player:isNude() then
        player:drawCards(1, self.name)
      else
        local choice1 = room:askForChoice(p1,
          { "#thbattle__shennaizi_xinyang-draw:" .. player.id, "#thbattle__shennaizi_xinyang-discard:" ..
          player.id }, self.name)
        if choice1 == "#thbattle__shennaizi_xinyang-draw:" .. player.id then
          player:drawCards(1, self.name)
        else
          local discard = room:askForCardChosen(p1, player, "he", self.name,
            "#thbattle__shennaizi_xinyang-choose_discard:" .. player.id)
          room:throwCard(discard, self.name, player, p1)
          local choice2 = room:askForChoice(player,
            { "#thbattle__shennaizi_xinyang-use_slash::" .. p1.id, "cancel" }, self.name)
          if choice2 ~= "cancel" then
            room:useCard({
              from = player.id,
              tos = { { p1.id } },
              card = Fk:cloneCard("danmu__slash"),
              extraUse = true,
            })
          end
        end
      end
    end
  end,
}



thbattle__shennaizi:addSkill(thbattle__shennaizi_shende)
thbattle__shennaizi:addSkill(thbattle__shennaizi_xinyang)

Fk:loadTranslationTable {
  ["thbattle__shennaizi"] = "八坂神奈子",
  ["#thbattle__shennaizi"] = "山丘与湖泊的化身",
  ["~thbattle__shennaizi"] = "各位我真的只要信仰，不要塞钱啊~",
  ["designer:thbattle__shennaizi"] = "Rem",
  ["cv:thbattle__shennaizi"] = "北斗夜/VV",
  ["illustrator:thbattle__shennaizi"] = "和茶",

  ["thbattle__shennaizi_shende"] = "神德",
  ["$thbattle__shennaizi_shende"] = "你脸黑~你多拿些信仰",
  [":thbattle__shennaizi_shende"] = "摸牌阶段，你可以放弃摸牌，改为令一名其他角色摸两张牌，然后其须展示并交给你一张牌，若交给你的牌为红桃牌，你摸一张牌。",
  ["#thbattle__shennaizi_shende"] = "神德:你可以放弃摸牌，改为令一名其他角色摸两张牌，然后其须展示并交给你一张牌，若交给你的牌为红桃牌，你摸一张牌。",
  ["#thbattle__shennaizi_shende-draw"] = "神德:你令一名其他角色摸两张牌",
  ["#thbattle__shennaizi_shende-give"] = "神德:你需交给%src一张牌，若为红桃牌，%src摸一张牌",

  ["thbattle__shennaizi_xinyang"] = "信仰",
  ["$thbattle__shennaizi_xinyang"] = "守矢的信仰，不知道被博丽她们搞到哪里去了",
  [":thbattle__shennaizi_xinyang"] = "限定技，出牌阶段，你可以令你攻击范围内的所有其他角色依次选择一项：" ..
      "<font color='red'>>></font> 令你摸一张牌。" ..
      "<font color='red'>>></font> 弃置你一张牌，然后你视为对其使用了一张弹幕或弹幕战（按此法使用的弹幕不消耗干劲）。",
  ["#thbattle__shennaizi_xinyang"] = "信仰:你可以令你攻击范围内的所有其他角色依次选择令你摸一张牌，或者其弃置你一张牌，然后你可对其视为使用一张【弹幕】",
  ["#thbattle__shennaizi_xinyang-draw"] = "信仰:令【%src】摸一张牌",
  ["#thbattle__shennaizi_xinyang-discard"] = "信仰:弃置【%src】一张牌，其可视为对你使用一张【弹幕】",
  ["#thbattle__shennaizi_xinyang-choose_discard"] = "信仰:你可以弃置【%src】一张牌",
  ["#thbattle__shennaizi_xinyang-use_slash"] = "信仰:对【%dest】视为使用一张【弹幕】",
}


-- 小小的甜蜜毒药 梅蒂欣 体力：3

-- 神经之毒：一名角色准备阶段开始时，你可以弃置一张黑色牌，令其失去1点体力并获得喝醉状态。

-- 忧郁之毒：每当你受到一次有来源的伤害后，你可以展示并获得牌堆顶的一张牌，若此牌不是梅花牌，伤害来源不能使用或打出手牌，直到回合结束。

-- KOF不平衡角色

-- （画师：和茶，CV：VV）


local thbattle__meidixin = General:new(extension, "thbattle__meidixin", "tho", 3, 3, 2)


local thbattle__meidixin_shenjingzhidu = fk.CreateTriggerSkill {
  name = "thbattle__meidixin_shenjingzhidu",
  prompt = "#thbattle__meidixin_shenjingzhidu",
  anim_type = "offensive",
  events = { fk.EventPhaseProceeding },
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target.phase == Player.Start and
        #table.filter(player:getCardIds("he"), function(cid)
          return Fk:getCardById(cid).color == Card.Black
        end) > 0
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if room:askForSkillInvoke(player, self.name) then
      return #room:askForDiscard(player, 1, 1, true, self.name, true, ".|.|spade,club",
        "#thbattle__meidixin_shenjingzhidu-discard:" .. target.id) > 0
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:loseHp(target, 1, self.name)
    THB_Utility.addStatusMark(target, "@@hezui")
  end
}

local thbattle__meidixin_youyuzhidu = fk.CreateTriggerSkill {
  name = "thbattle__meidixin_youyuzhidu",
  anim_type = "masochism",
  events = { fk.Damaged },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.from and data.from ~= player
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, "#thbattle__meidixin_youyuzhidu:" .. target.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local target_card = room:getNCards(1)[1]
    room:obtainCard(player, target_card, true, fk.ReasonPrey, player.id, self.name)
    player:showCards(target_card)
    if Fk:getCardById(target_card).suit ~= Card.Club then
      THB_Utility.addStatusMark(data.from, "@@thbattle__meidixin_youyuzhidu-turn")
    end
  end
}
local thbattle__meidixin_youyuzhidu_prohibit = fk.CreateProhibitSkill {
  name = "#thbattle__meidixin_youyuzhidu_prohibit",
  prohibit_use = function(self, player, card)
    if player:getMark("@@thbattle__meidixin_youyuzhidu-turn") > 0 then
      local subcards = card:isVirtual() and card.subcards or { card.id }
      return #subcards > 0 and
          table.every(subcards, function(id) return table.contains(player:getCardIds(Player.Hand), id) end)
    end
  end,
  prohibit_response = function(self, player, card)
    if player:getMark("@@thbattle__meidixin_youyuzhidu-turn") > 0 then
      local subcards = card:isVirtual() and card.subcards or { card.id }
      return #subcards > 0 and
          table.every(subcards, function(id) return table.contains(player:getCardIds(Player.Hand), id) end)
    end
  end,
}


thbattle__meidixin_youyuzhidu:addRelatedSkill(thbattle__meidixin_youyuzhidu_prohibit)
thbattle__meidixin:addSkill(thbattle__meidixin_shenjingzhidu)
thbattle__meidixin:addSkill(thbattle__meidixin_youyuzhidu)
Fk:loadTranslationTable {
  ["thbattle__meidixin"] = "梅蒂欣",
  ["#thbattle__meidixin"] = "小小的甜蜜毒药",
  ["~thbattle__meidixin"] = "这铃兰的花香，你..诶？！是蜜蜂啊..",
  ["designer:thbattle__meidixin"] = "Rem",
  ["cv:thbattle__meidixin"] = "VV",
  ["illustrator:thbattle__meidixin"] = "和茶",

  ["thbattle__meidixin_shenjingzhidu"] = "神经之毒",
  ["$thbattle__meidixin_shenjingzhidu"] = "快来尝一尝，这小小的甜蜜毒药",
  [":thbattle__meidixin_shenjingzhidu"] = "一名角色准备阶段开始时，你可以弃置一张黑色牌，令其失去1点体力并获得【喝醉】状态。",
  ["#thbattle__meidixin_shenjingzhidu"] = "神经之毒:你可以弃置一张黑色牌，令其失去1点体力并获得【喝醉】状态。",
  ["#thbattle__meidixin_shenjingzhidu-discard"] = "神经之毒:你可以弃置一张黑色牌，令%src失去1点体力并获得【喝醉】状态。",

  ["thbattle__meidixin_youyuzhidu"] = "忧郁之毒",
  ["$thbattle__meidixin_youyuzhidu"] = "这铃兰的花香，你可感觉的到",
  [":thbattle__meidixin_youyuzhidu"] = "每当你受到一次有来源的伤害后，你可以展示并获得牌堆顶的一张牌，若此牌不是梅花牌，伤害来源不能使用或打出手牌，直到回合结束。",
  ["#thbattle__meidixin_youyuzhidu"] = "忧郁之毒:你可以展示并获得牌堆顶的一张牌，若此牌不是梅花牌，%src不能使用或打出手牌，直到回合结束。",
  ["@@thbattle__meidixin_youyuzhidu-turn"] = "忧郁之毒",
}


-- 幻想乡最速 射命丸文 体力：4

-- 最速：锁定技，你的回合内，当你使用本回合的第二张牌时，你摸一张牌，然后你使用卡牌时无距离限制，直到回合结束。

-- （画师：渚FUN，CV：君寻）

local thbattle__wen = General:new(extension, "thbattle__wen", "tho", 4, 4, 2)


local thbattle__wen_zuisu = fk.CreateTriggerSkill {
  name = "thbattle__wen_zuisu",
  frequency = Skill.Compulsory,
  anim_type = "drawcard",
  events = { fk.CardUsing },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase ~= Player.NotActive and
        #player.room.logic:getEventsOfScope(GameEvent.UseCard, 2, function(e)
          local use = e.data[1]
          return use.from == player.id
        end, Player.HistoryTurn) > 1 and player:getMark("@@thbattle__wen_zuisu-turn") == 0
  end,

  on_use = function(self, event, target, player, data)
    local room = player.room
    player:drawCards(1, self.name)
    THB_Utility.addStatusMark(player, "@@thbattle__wen_zuisu-turn")
  end
}

local thbattle__wen_zuisu_targetmod = fk.CreateTargetModSkill {
  name = "#thbattle__wen_zuisu_targetmod",
  bypass_distances = function(self, player, skill, card, to)
    return player:getMark("@@thbattle__wen_zuisu-turn") > 0
  end,
}

thbattle__wen_zuisu:addRelatedSkill(thbattle__wen_zuisu_targetmod)
thbattle__wen:addSkill(thbattle__wen_zuisu)
Fk:loadTranslationTable {
  ["thbattle__wen"] = "射命丸文",
  ["#thbattle__wen"] = "幻想乡最速",
  ["~thbattle__wen"] = "呃啊，被追上了吗",
  ["designer:thbattle__wen"] = "Rem",
  ["cv:thbattle__wen"] = "君寻",
  ["illustrator:thbattle__wen"] = "渚FUN",

  ["thbattle__wen_zuisu"] = "最速",
  ["$thbattle__wen_zuisu"] = "接下来，我可要加速了哦",
  [":thbattle__wen_zuisu"] = "锁定技，你的回合内，当你使用本回合的第二张牌时，你摸一张牌，然后你使用卡牌时无距离限制，直到回合结束。",
  ["@@thbattle__wen_zuisu-turn"] = "最速",

}

-- 玩坏你哦 SP芙兰朵露 体力：4

-- 破坏冲动：锁定技，结束阶段结束后，若你本回合没有造成过伤害，你对距离最近的一名其他角色造成1点伤害，并失去1点体力。

-- 四重存在：每当你受到一次不大于你当前体力值的伤害时，你可以减少1点体力上限并防止此伤害；你体力值为1时，你为伤害来源的卡牌造成的伤害+1。

-- （画师：Vivicat@幻想梦斗符，CV：shourei小N）

local thbattle__sp_fulanduolu = General:new(extension, "thbattle__sp_fulanduolu", "tho", 4, 4, 2)


local thbattle__sp_fulanduolu_pohuaichongdong = fk.CreateTriggerSkill {
  name = "thbattle__sp_fulanduolu_pohuaichongdong",
  frequency = Skill.Compulsory,
  anim_type = "offensive",
  events = { fk.EventPhaseEnd },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Finish and
        #player.room.logic:getActualDamageEvents(1, function(e)
          local damageEvent = e.data[1]
          return damageEvent.from == player
        end, Player.HistoryTurn) == 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local other_players = room:getOtherPlayers(player)
    local luanwu_targets = table.map(table.filter(other_players, function(p2)
      return table.every(other_players, function(p1)
        return target:distanceTo(p1) >= target:distanceTo(p2)
      end)
    end), function(p)
      return p.id
    end)
    local target_player = room:askForChoosePlayers(player, luanwu_targets, 1, 1,
      "#thbattle__sp_fulanduolu_pohuaichongdong"
      , self.name, false)[1]
    room:damage({
      from = player,
      to = room:getPlayerById(target_player),
      damage = 1,
      skillName = self.name
    })
    room:loseHp(player, 1, self.name)
  end
}

local thbattle__sp_fulanduolu_sichongcunzai = fk.CreateTriggerSkill {
  name = "thbattle__sp_fulanduolu_sichongcunzai",
  prompt = "#thbattle__sp_fulanduolu_sichongcunzai",
  anim_type = "defensive",
  events = { fk.DamageInflicted },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.damage <= player.hp
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:changeMaxHp(player, -1)
    return true
  end
}

local thbattle__sp_fulanduolu_sichongcunzai_damage = fk.CreateTriggerSkill {
  name = "#thbattle__sp_fulanduolu_sichongcunzai_damage",
  prompt = "#thbattle__sp_fulanduolu_sichongcunzai_damage-prompt",
  anim_type = "defensive",
  events = { fk.DamageCaused },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card and player.hp == 1
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    data.damage = (data.damage or 0) + 1
  end
}

thbattle__sp_fulanduolu_sichongcunzai:addRelatedSkill(thbattle__sp_fulanduolu_sichongcunzai_damage)
thbattle__sp_fulanduolu:addSkill(thbattle__sp_fulanduolu_pohuaichongdong)
thbattle__sp_fulanduolu:addSkill(thbattle__sp_fulanduolu_sichongcunzai)
Fk:loadTranslationTable {
  ["thbattle__sp_fulanduolu"] = "SP芙兰朵露",
  ["#thbattle__sp_fulanduolu"] = "玩坏你哦",
  ["~thbattle__sp_fulanduolu"] = "又只剩下芙兰一个人了...",
  ["designer:thbattle__sp_fulanduolu"] = "Rem",
  ["cv:thbattle__sp_fulanduolu"] = "shourei小N",
  ["illustrator:thbattle__sp_fulanduolu"] = "Vivicat@幻想梦斗符",

  ["thbattle__sp_fulanduolu_pohuaichongdong"] = "破坏冲动",
  ["$thbattle__sp_fulanduolu_pohuaichongdong"] = "来陪我玩吧~嘻嘻嘻",
  [":thbattle__sp_fulanduolu_pohuaichongdong"] = "锁定技，结束阶段结束后，若你本回合没有造成过伤害，你对距离最近的一名其他角色造成1点伤害，并失去1点体力。",
  ["#thbattle__sp_fulanduolu_pohuaichongdong"] = "破坏冲动:你对距离最近的一名其他角色造成1点伤害，并失去1点体力。",

  ["thbattle__sp_fulanduolu_sichongcunzai"] = "四重存在",
  ["$thbattle__sp_fulanduolu_sichongcunzai"] = "在这里哟~在这里哟~",
  [":thbattle__sp_fulanduolu_sichongcunzai"] = "每当你受到一次不大于你当前体力值的伤害时，你可以减少1点体力上限并防止此伤害；你体力值为1时，你为伤害来源的卡牌造成的伤害+1。",
  ["#thbattle__sp_fulanduolu_sichongcunzai"] = "四重存在:你可以减少1点体力上限并防止此伤害",
  ["#thbattle__sp_fulanduolu_sichongcunzai_damage"] = "四重存在",
  ["#thbattle__sp_fulanduolu_sichongcunzai_damage-prompt"] = "四重存在:你为伤害来源的卡牌造成的伤害+1。",

}


-- 永琳的首席药品品尝官 铃仙 体力：4

-- 狂气：当你使用弹幕或弹幕战对其他角色造成伤害后，你可以令其获得技能丧心。
-- >> 丧心：锁定技，出牌阶段，你不能使用弹幕以外的牌；你使用弹幕只能指定距离最近的目标；结束阶段开始时，你失去此技能。

-- 生药：每当你因使用麻薯回复体力后，你可以获得喝醉状态。

-- （画师：镜_Area@幻想梦斗符，CV：小羽）

local thbattle__lingxian = General:new(extension, "thbattle__lingxian", "tho", 4, 4, 2)
local thbattle__lingxian_kuangqi = fk.CreateTriggerSkill {
  name = "thbattle__lingxian_kuangqi",
  prompt = "#thbattle__lingxian_kuangqi",
  anim_type = "control",
  events = { fk.Damage },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card and
        (data.card.trueName == "slash" or data.card.trueName == "duel")
        and data.to and data.to ~= player and data.to:getMark("@@thbattle__lingxian_sangxin")==0
  end,
  on_use = function(self, event, target, player, data)
    player.room:handleAddLoseSkills(data.to, "thbattle__lingxian_sangxin", nil, true, false)
    THB_Utility.addStatusMark(data.to, "@@thbattle__lingxian_sangxin",1,player.room)
  end,
}
local thbattle__lingxian_sangxin = fk.CreateProhibitSkill {
  name = "thbattle__lingxian_sangxin",
  frequency = Skill.Compulsory,
  prohibit_use = function(self, player, card)
    return player.phase == Player.Play and player:getMark("@@thbattle__lingxian_sangxin") > 0 and card and
        card.trueName ~= "slash"
  end,
  is_prohibited = function(self, from, to, card)
    local room = Fk:currentRoom()
    if from:getMark("@@thbattle__lingxian_sangxin") > 0 and card and from.phase == Player.Play and card.trueName == "slash" then
      if to then
        local room = Fk:currentRoom()
        local player = from
        ---获取最近距离
        local n = 999
        for _, p in ipairs(room.alive_players) do
          if p ~= player and player:distanceTo(p) < n then
            n = player:distanceTo(p)
          end
        end
        ---

        ---找最近距离的角色
        local targets = table.map(table.filter(room.alive_players, function(p)
          return player:distanceTo(p) == n
        end), function(p) return p.id end)
        return not table.contains(targets, to.id)
      end
    end
  end,
}
local thbattle__lingxian_sangxin_trigger = fk.CreateTriggerSkill {
  name = "#thbattle__lingxian_sangxin_trigger",
  frequency = Skill.Compulsory,
  mute = true,
  refresh_events = { fk.EventPhaseStart },
  can_refresh = function(self, event, target, player, data)
    return target == player and player:getMark("@@thbattle__lingxian_sangxin") > 0 and player.phase == Player.Finish
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:removePlayerMark(player, "@@thbattle__lingxian_sangxin")
    player.room:handleAddLoseSkills(player, "-thbattle__lingxian_sangxin", nil, true, false)
  end,
}

local thbattle__lingxian_shengyao = fk.CreateTriggerSkill {
  name = "thbattle__lingxian_shengyao",
  prompt = "#thbattle__lingxian_shengyao",
  anim_type = "offensive",
  events = { fk.HpRecover },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card and data.card.trueName == "peach"
  end,
  on_use = function(self, event, target, player, data)
    THB_Utility.addStatusMark(player, "@@hezui")
  end,
}

thbattle__lingxian_sangxin:addRelatedSkill(thbattle__lingxian_sangxin_trigger)
thbattle__lingxian:addSkill(thbattle__lingxian_kuangqi)
thbattle__lingxian:addSkill(thbattle__lingxian_shengyao)
thbattle__lingxian:addRelatedSkill(thbattle__lingxian_sangxin)

Fk:loadTranslationTable {
  ["thbattle__lingxian"] = "铃仙",
  ["~thbattle__lingxian"] = "师傅，这药————🐇",
  ["#thbattle__lingxian"] = "永琳的首席药品品尝官",
  ["designer:thbattle__lingxian"] = "Rem",
  ["cv:thbattle__lingxian"] = "小羽",
  ["illustrator:thbattle__lingxian"] = "镜_Area@幻想梦斗符",

  ["thbattle__lingxian_kuangqi"] = "狂气",
  ["$thbattle__lingxian_kuangqi1"] = "根本停不下来！！🏃‍",
  ["$thbattle__lingxian_kuangqi2"] = "给你们看看全部的！月的疯狂！🌙",
  ["#thbattle__lingxian_kuangqi"] = "狂气：你可以令其获得技能【丧心】直到其结束阶段开始时。",
  [":thbattle__lingxian_kuangqi"] = "当你使用【弹幕】或【弹幕战】对其他角色造成伤害后，你可以令其获得技能【<a href=':thbattle__lingxian_sangxin'><font color='red'>丧心</font></a>】。" ..
      "<font color='red'>>></font> 丧心：锁定技，出牌阶段，你不能使用【弹幕】以外的牌；你使用【弹幕】只能指定距离最近的目标；结束阶段开始时，你失去此技能。",

  ["thbattle__lingxian_sangxin"] = "丧心",
  [":thbattle__lingxian_sangxin"] = "锁定技，出牌阶段，你不能使用【弹幕】以外的牌；你使用【弹幕】只能指定距离最近的目标；结束阶段开始时，你失去此技能。",
  ["@@thbattle__lingxian_sangxin"] = "丧心",

  ["thbattle__lingxian_shengyao"] = "生药",
  ["$thbattle__lingxian_shengyao"] = "国士无双之药‍，认准蓝瓶的😊",
  ["#thbattle__lingxian_shengyao"] = "生药：你可以获得【喝醉】状态。",
  [":thbattle__lingxian_shengyao"] = "每当你因使用麻薯回复体力后，你可以获得【喝醉】状态。",
}



-- 进击的小人 少名针妙丸 体力：4

-- 万宝槌：当一名角色的判定牌生效前，你可以用一张点数大于此牌的牌替换之。
-- 付丧神之怨：每当其他角色装备区的牌因弃置而置入弃牌堆时，你可以进行一次判定，若为9~K，你对其造成1点伤害。
-- （画师：六仔OwO，CV：小羽，人物设计：yourccz95）
local thbattle__xiaowan = General:new(extension, "thbattle__xiaowan", "tho", 4, 4, 2)
local thbattle__xiaowan_wanbaochui = fk.CreateTriggerSkill {
  name = "thbattle__xiaowan_wanbaochui",
  prompt = "#thbattle__xiaowan_wanbaochui",
  anim_type = "control",
  events = { fk.AskForRetrial },
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and not player:isNude() and data.card.number < 13
  end,
  on_cost = function(self, event, target, player, data)
    local num = data.card.number + 1
    local card = player.room:askForResponse(player, self.name, ".|" .. num .. "~13" .. "|.|hand,equip",
      "#thbattle__xiaowan_wanbaochui-ask::" .. target.id .. ":" .. data.reason, true)
    if card ~= nil then
      self.cost_data = card
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:retrial(self.cost_data, player, data, self.name, true)
  end,

}

local thbattle__xiaowan_fusangshen = fk.CreateTriggerSkill {
  name = "thbattle__xiaowan_fusangshen",
  prompt = "#thbattle__xiaowan_fusangshen",
  anim_type = "offensive",
  events = { fk.AfterCardsMove },
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return end
    for _, move in ipairs(data) do
      if move.from and move.from ~= player.id and move.moveReason == fk.ReasonDiscard then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerEquip and player.room:getCardArea(info.cardId) == Card.DiscardPile and
              #U.moveCardsHoldingAreaCheck(player.room, { info.cardId }) > 0 then
            return true
          end
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    for _, move in ipairs(data) do
      if move.from and move.from ~= player.id and move.moveReason == fk.ReasonDiscard then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerEquip and player.room:getCardArea(info.cardId) == Card.DiscardPile and
              #U.moveCardsHoldingAreaCheck(player.room, { info.cardId }) > 0 then
            local judge = {
              who = player,
              reason = self.name,
              pattern = ".|9~13",
            }
            player.room:judge(judge)
            if judge.card.number >= 9 then
              player.room:damage({
                from = player,
                to = player.room:getPlayerById(move.from),
                damage = 1,
                skillName = self.name
              })
            end
          end
        end
      end
    end
  end,

}

thbattle__xiaowan:addSkill(thbattle__xiaowan_wanbaochui)
thbattle__xiaowan:addSkill(thbattle__xiaowan_fusangshen)

Fk:loadTranslationTable {
  ["thbattle__xiaowan"] = "少名针妙丸",
  ["~thbattle__xiaowan"] = "人与人之间最基本的信任呢~~",
  ["#thbattle__xiaowan"] = "进击的小人",
  ["designer:thbattle__xiaowan"] = "Rem",
  ["cv:thbattle__xiaowan"] = "小羽",
  ["illustrator:thbattle__xiaowan"] = "六仔OwO",

  ["thbattle__xiaowan_wanbaochui"] = "万宝槌",
  ["$thbattle__xiaowan_wanbaochui1"] = "大，大，大！",
  ["$thbattle__xiaowan_wanbaochui2"] = "快到碗里来~",
  ["#thbattle__xiaowan_wanbaochui"] = "万宝槌：当一名角色的判定牌生效前，你可以用一张点数大于此牌的牌替换之。",
  [":thbattle__xiaowan_wanbaochui"] = "当一名角色的判定牌生效前，你可以用一张点数大于此牌的牌替换之。",
  ["#thbattle__xiaowan_wanbaochui-ask"] = "万宝槌：你可以打出一张点数大于此牌的牌替换 %dest 的 “%arg” 判定",


  ["thbattle__xiaowan_fusangshen"] = "付丧神之怨",
  ["$thbattle__xiaowan_fusangshen1"] = "脱下来的姿势不对啦~",
  ["$thbattle__xiaowan_fusangshen2"] = "稍有常识的人都会看出，如果怨念的装备继续前进~哼~",
  ["#thbattle__xiaowan_fusangshen"] = "付丧神之怨：你可以进行一次判定，若为9~K，你对其造成1点伤害。",
  [":thbattle__xiaowan_fusangshen"] = "每当其他角色装备区的牌因弃置而置入弃牌堆时，你可以进行一次判定，若为9~K，你对其造成1点伤害。",
}


-- 水中的工程师 河城荷取 体力：3

-- 拆解：出牌阶段限一次，你可以重铸一名其他角色装备区里的一张装备牌，然后你摸一张牌。

-- 匠心：你可以将你的全部手牌（至少1张）当做任意的一张基本牌使用或打出。你的回合以此方式使用牌时，一回合限一次。

-- KOF不平衡角色

-- （画师：和茶，CV：简翎）


local thbattle__hecheng = General:new(extension, "thbattle__hecheng", "tho", 3, 3, 2)
local thbattle__hecheng_chaijie = fk.CreateActiveSkill {
  name = "thbattle__hecheng_chaijie",
  anim_type = "drawcard",
  prompt = "#thbattle__hecheng_chaijie",
  target_num = 1,
  target_filter = function(self, to_select, selected, selected_cards, card, extra_data,user)
    return #selected == 0 and #Fk:currentRoom():getPlayerById(to_select):getCardIds("e") > 0 and to_select ~= user.id
  end,
  max_phase_use_time = 1,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local target_cid = room:askForCardChosen(player, target, "e", self.name, "#thbattle__hecheng_chaijie-choose_card")
    room:recastCard(target_cid, target, self.name)
    player:drawCards(1, self.name)
  end,
}

local thbattle__hecheng_jiangxin = fk.CreateViewAsSkill {
  name = "thbattle__hecheng_jiangxin",
  prompt = "#thbattle__hecheng_jiangxin",
  pattern = ".",
  interaction = function()
    local names = {}
    for _, id in ipairs(Fk:getAllCardIds()) do
      local card = Fk:getCardById(id)
      if card.type == Card.TypeBasic and not card.is_derived then
        local to_use = Fk:cloneCard(card.name)
        if ((Fk.currentResponsePattern == nil and Self:canUse(to_use) and not Self:prohibitUse(to_use)) or
              (Fk.currentResponsePattern and Exppattern:Parse(Fk.currentResponsePattern):match(to_use))) then
          table.insertIfNeed(names, card.name)
        end
      end
    end
    if #names == 0 then return false end
    return UI.ComboBox { choices = names }
  end,
  view_as = function(self, cards,user)
    if user:isKongcheng() or not self.interaction.data then return end
    local card = Fk:cloneCard(self.interaction.data)
    card:addSubcards(user:getCardIds("h"))
    card.skillName = self.name
    return card
  end,
  enabled_at_play = function(self, player)
    if not player:isKongcheng() then
      if player.phase == Player.NotActive then
        return true
      else
        return player:usedSkillTimes(self.name) == 0
      end
    end
  end,
  enabled_at_response = function(self, player, response)
    return true
  end,
}

thbattle__hecheng:addSkill(thbattle__hecheng_chaijie)
thbattle__hecheng:addSkill(thbattle__hecheng_jiangxin)

Fk:loadTranslationTable {
  ["thbattle__hecheng"] = "河城荷取",
  ["~thbattle__hecheng"] = "超妖怪弹头~",
  ["#thbattle__hecheng"] = "水中的工程师",
  ["designer:thbattle__hecheng"] = "Rem",
  ["cv:thbattle__hecheng"] = "简翎",
  ["illustrator:thbattle__hecheng"] = "和茶",

  ["thbattle__hecheng_chaijie"] = "拆解",
  ["$thbattle__hecheng_chaijie1"] = "费用的话，给黄瓜就好了~",
  ["$thbattle__hecheng_chaijie2"] = "回收回收~",
  ["#thbattle__hecheng_chaijie"] = "拆解：你可以重铸一名其他角色装备区里的一张装备牌，然后你摸一张牌。",
  [":thbattle__hecheng_chaijie"] = "出牌阶段限一次，你可以重铸一名其他角色装备区里的一张装备牌，然后你摸一张牌。",
  ["#thbattle__hecheng_chaijie-choose_card"] = "拆解：你可以重铸一名其他角色装备区里的一张装备牌，然后你摸一张牌。",


  ["thbattle__hecheng_jiangxin"] = "匠心",
  ["$thbattle__hecheng_jiangxin1"] = "当当当当~",
  ["$thbattle__hecheng_jiangxin2"] = "全弹发射！",
  ["#thbattle__hecheng_jiangxin"] = "匠心：你可以进行一次判定，若为9~K，你对其造成1点伤害。",
  [":thbattle__hecheng_jiangxin"] = "你可以将你的全部手牌（至少1张）当做任意的一张基本牌使用或打出。你的回合以此方式使用牌时，一回合限一次。",
}


-- 寂寞与终焉的象征 秋静叶 体力：3

-- 凋零：锁定技。你的回合内，每当其他角色失去最后的手牌时，你摸一张牌；你的回合外，每当你受到一次伤害后，当前回合角色于本回合弃牌阶段需额外弃置一张手牌（该效果不可叠加）。

-- 秋风：弃牌阶段结束时，你可以弃置至多X名角色各一张牌。（X为你本阶段弃置的手牌数）

-- （画师：和茶，CV：VV，人物设计：SmiteOfKing

local thbattle__qiujingye = General:new(extension, "thbattle__qiujingye", "tho", 3, 3, 2)

local thbattle__qiujingye_diaoling = fk.CreateTriggerSkill {
  name = "thbattle__qiujingye_diaoling",
  mute = true,
  frequency = Skill.Compulsory,
  events = { fk.AfterCardsMove, fk.Damaged },
  can_trigger = function(self, event, target, player, data)
    if event == fk.AfterCardsMove then
      if not player:hasSkill(self) or player.phase == Player.NotActive then return end
      for _, move in ipairs(data) do
        if move.from and move.from ~= player.id and player.room:getPlayerById(move.from):isKongcheng() then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.PlayerHand then
              return true
            end
          end
        end
      end
    else
      return target == player and player:hasSkill(self) and player.phase == Player.NotActive and player:isAlive() and
          player.room.current:getMark("@@thbattle__qiujingye_diaoling-turn") == 0
    end
  end,
  on_use = function(self, event, target, player, data)
    if event == fk.AfterCardsMove then
      player:broadcastSkillInvoke(self.name)
      player.room:notifySkillInvoked(player, self.name, "drawcard")
      player:drawCards(1, self.name)
    else
      player:broadcastSkillInvoke(self.name)
      player.room:notifySkillInvoked(player, self.name, "masochism")
      THB_Utility.addStatusMark(player.room.current, "@@thbattle__qiujingye_diaoling-turn")
    end
  end,

}

local thbattle__qiujingye_diaoling_discard = fk.CreateTriggerSkill {
  name = "#thbattle__qiujingye_diaoling_discard",
  mute=true,
  frequency = Skill.Compulsory,
  events = { fk.EventPhaseEnd },
  can_trigger = function(self, event, target, player, data)
    return target==player and player:getMark("@@thbattle__qiujingye_diaoling-turn")>0 and player.phase==Player.Discard and not player:isKongcheng()
  end,
  on_use = function(self, event, target, player, data)
    local room=player.room
    room:askForDiscard(player,1,1,false,self.name,false,".","#thbattle__qiujingye_diaoling_discard-prompt")
    THB_Utility.removeStatusMark(player,"@@thbattle__qiujingye_diaoling")
  end,

}

local thbattle__qiujingye_qiufeng = fk.CreateTriggerSkill {
  name = "thbattle__qiujingye_qiufeng",
  prompt = "#thbattle__qiujingye_qiufeng",
  anim_type = "control",
  events = { fk.EventPhaseEnd },
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(self) and target.phase == Player.Discard then
      local to_select_players = table.filter(player.room:getOtherPlayers(player), function(p)
        return not p:isNude()
      end)
      local ids = {}
      player.room.logic:getEventsOfScope(GameEvent.MoveCards, 1, function(e)
        for _, move in ipairs(e.data) do
          if move.toArea == Card.DiscardPile then
            for _, info in ipairs(move.moveInfo) do
              if player.room:getCardArea(info.cardId) == Card.DiscardPile then
                table.insertIfNeed(ids, info.cardId)
              end
            end
          end
        end
        return false
      end, Player.HistoryPhase)
      if #ids > 0 then
        self.cost_data = #ids
        return #to_select_players > 0
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, "#thbattle__qiujingye_qiufeng:::" .. self.cost_data)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local num = self.cost_data
    local to_select_players = table.filter(room:getOtherPlayers(player), function(p)
      return not p:isNude()
    end)
    if #to_select_players > 0 then
      local target_players = room:askForChoosePlayers(player, table.map(to_select_players, Util.IdMapper), 1
      , math.min(num, #to_select_players), "#thbattle__qiujingye_qiufeng-choose_players", true)
      if #target_players > 0 then
        for _, pid in ipairs(target_players) do
          local target_p = room:getPlayerById(pid)
          local choose_cid = room:askForCardChosen(player, target_p, "he", self.name,
            "#thbattle__qiujingye_qiufeng-choose_card")
          room:throwCard(choose_cid, self.name, target_p, player)
        end
      end
    end
  end,

}

thbattle__qiujingye_diaoling:addRelatedSkill(thbattle__qiujingye_diaoling_discard)
thbattle__qiujingye:addSkill(thbattle__qiujingye_diaoling)
thbattle__qiujingye:addSkill(thbattle__qiujingye_qiufeng)

Fk:loadTranslationTable {
  ["thbattle__qiujingye"] = "秋静叶",
  ["~thbattle__qiujingye"] = "咦？黑幕来了，大家快逃！",
  ["#thbattle__qiujingye"] = "寂寞与终焉的象征",
  ["designer:thbattle__qiujingye"] = "Rem",
  ["cv:thbattle__qiujingye"] = "VV",
  ["illustrator:thbattle__qiujingye"] = "和茶",

  ["thbattle__qiujingye_diaoling"] = "凋零",
  ["$thbattle__qiujingye_diaoling"] = "叶子的离去，是风的追求，还是树的不挽留~",
  [":thbattle__qiujingye_diaoling"] = "锁定技。你的回合内，每当其他角色失去最后的手牌时，你摸一张牌；你的回合外，每当你受到一次伤害后，当前回合角色于本回合弃牌阶段需额外弃置一张手牌（该效果不可叠加）。",
  ["@@thbattle__qiujingye_diaoling-turn"] = "凋零",
  ["#thbattle__qiujingye_diaoling_discard"]="凋零",
  ["#thbattle__qiujingye_diaoling_discard-prompt"]="凋零:请弃置一张牌",

  ["thbattle__qiujingye_qiufeng"] = "秋风",
  ["$thbattle__qiujingye_qiufeng"] = "觉得冷吗？谁叫你们不穿秋裤",
  ["#thbattle__qiujingye_qiufeng"] = "秋风：你可以弃置至多%arg名角色各一张牌",
  [":thbattle__qiujingye_qiufeng"] = "弃牌阶段结束时，你可以弃置至多X名角色各一张牌。（X为你本阶段弃置的手牌数）",
  ["#thbattle__qiujingye_qiufeng-choose_players"] = "秋风：请选择你弃置其牌的角色",
  ["#thbattle__qiujingye_qiufeng-choose_card"] = "秋风：选择一张牌弃置",

}

-- 诵经的山彦 幽谷响子 体力：4

-- 回响：每当你受到一次伤害后，你可以获得对你造成伤害的牌，若此牌为弹幕，你可以改为令一名其他角色获得之。

-- 共振：当你对其他角色使用的弹幕结算完毕后，你可以指定另一名其他角色，被指定角色可以对其使用一张无视距离的弹幕。

-- （画师：月见，CV：小羽，人物设计：蝶之羽风暂留此）

local thbattle__xiangzi = General:new(extension, "thbattle__xiangzi", "tho", 4, 4, 2)

local thbattle__xiangzi_huixiang = fk.CreateTriggerSkill {
  name = "thbattle__xiangzi_huixiang",
  prompt = "#thbattle__xiangzi_huixiang",
  anim_type = "masochism",
  events = { fk.Damaged },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local target = player
    if data.card.trueName == "slash" then
      target = room:askForChoosePlayers(player, table.map(room:getOtherPlayers(player), Util.IdMapper), 1, 1,
        "#thbattle__xiangzi_huixiang-choose_player", self.name, true)
      if #target == 0 then
        target = player
      else
        target = target[1]
      end
    end
    room:obtainCard(target, data.card, true, fk.ReasonPrey, player.id, self.name)
  end,

}

local thbattle__xiangzi_gongzhen = fk.CreateTriggerSkill {
  name = "thbattle__xiangzi_gongzhen",
  anim_type = "offensive",
  events = { fk.CardEffectFinished },
  can_trigger = function(self, event, target, player, data)
    return target ~= player and player:hasSkill(self) and data.card and data.card.trueName == "slash" and
        data.from == player.id
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room:getOtherPlayers(player), function(p)
      return not p:isProhibited(target, Fk:cloneCard("slash")) and p ~= target
    end)
    if #targets > 0 then
      if room:askForSkillInvoke(player, self.name, nil, "#thbattle__xiangzi_gongzhen::" .. target.id) then
        local targetPlayer = room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1,
          "#thbattle__xiangzi_gongzhen-choose_player", self.name, true)
        if #targetPlayer > 0 then
          self.cost_data = targetPlayer[1]
          return true
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targetPlayer = room:getPlayerById(self.cost_data)
    local use = room:askForUseCard(targetPlayer, "slash", ".", "#thbattle__xiangzi_gongzhen-use_slash::" .. target
      .id
      , true, { bypass_distances = true, bypass_times = true, exclusive_targets = { target.id } })
    if use then
      room:useCard(use)
    end
  end,

}

thbattle__xiangzi:addSkill(thbattle__xiangzi_huixiang)
thbattle__xiangzi:addSkill(thbattle__xiangzi_gongzhen)

Fk:loadTranslationTable {
  ["thbattle__xiangzi"] = "幽谷响子",
  ["~thbattle__xiangzi"] = "要回去念经了...",
  ["#thbattle__xiangzi"] = "诵经的山彦",
  ["designer:thbattle__xiangzi"] = "Rem",
  ["cv:thbattle__xiangzi"] = "小羽",
  ["illustrator:thbattle__xiangzi"] = "月见",

  ["thbattle__xiangzi_huixiang"] = "回响",
  ["$thbattle__xiangzi_huixiang"] = "呀哟~~",
  [":thbattle__xiangzi_huixiang"] = "每当你受到一次伤害后，你可以获得对你造成伤害的牌，若此牌为【弹幕】，你可以改为令一名其他角色获得之。",
  ["#thbattle__xiangzi_huixiang"] = "回响:你可以获得对你造成伤害的牌，若此牌为【弹幕】，你可以改为令一名其他角色获得之。",
  ["#thbattle__xiangzi_huixiang-choose_player"] = "回响:你可以改为令一名其他角色获得之。",


  ["thbattle__xiangzi_gongzhen"] = "共振",
  ["$thbattle__xiangzi_gongzhen"] = "普通的弹幕，我们普通的摇",
  ["#thbattle__xiangzi_gongzhen"] = "共振：你可以指定另一名其他角色，被指定角色可以对其使用一张无视距离的弹幕。",
  [":thbattle__xiangzi_gongzhen"] = "当你对其他角色使用的弹幕结算完毕后，你可以指定另一名其他角色，被指定角色可以对其使用一张无视距离的弹幕。",
  ["#thbattle__xiangzi_gongzhen-choose_player"] = "共振：你可以指定另一名其他角色，被指定角色可以对%dest使用一张无视距离的弹幕。",
  ["#thbattle__xiangzi_gongzhen-use_slash"] = "共振：可以对%dest使用一张无视距离的弹幕。",

}


-- 人间之里的守护者 上白泽慧音 体力：4

-- 授业：出牌阶段限一次，你可以重铸一张牌，然后将一张牌交给一名其它角色，其选择一项：>> 使用一张牌，>> 重铸一张牌。

-- 守护：限定技，出牌阶段开始时，你可以失去一点体力上限，令一名其它已受伤角色回复一点体力。
--       之后，若其体力仍然是全场最低的，则你与其获得技能决意。

-- >> 决意：锁定技，当你受到伤害时，若同样拥有决意的另一名角色的体力值比你高，则伤害改为由该角色承受。
-- 同样拥有决意的另一名角色于你的回合内摸牌/回复体力时，你摸相同数量的牌/回复相同的体力。

-- KOF不平衡角色

-- （画师：和茶，CV：银子）

local thbattle__huiyin = General:new(extension, "thbattle__huiyin", "tho", 4, 4, 2)

local thbattle__huiyin_shouye = fk.CreateActiveSkill {
  name = "thbattle__huiyin_shouye",
  prompt = "#thbattle__huiyin_shouye",
  anim_type = "support",
  card_num = 1,
  card_filter =function (self, to_select, selected, user)
    return #selected < 1
  end,
  target_num = 1,
  target_filter = function(self, to_select, selected, selected_cards, card, extra_data,user)
    return #selected == 0 and user.id ~= to_select
  end,
  can_use = function(self, player, card, extra_data)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 and not player:isNude()
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    room:recastCard(effect.cards, player, self.name)
    if not player:isNude() then
      local card = room:askForCard(player, 1, 1, true, self.name, false, nil, "#thbattle__huiyin_shouye-give:" .. target
        .id)
      room:obtainCard(target, card, false, fk.ReasonGive, player.id, self.name)
      if not target:isNude() then
        local use = U.askForPlayCard(room, target, nil, nil, self.name, "#thbattle__huiyin_shouye-use",
          { bypass_times = true }, true)
        if use then
          use.card.skillName = self.name
          room:useCard(use)
        else
          local card = room:askForCard(target, 1, 1, true, self.name, false, nil, "#thbattle__huiyin_shouye-recast")
          room:recastCard(card, target, self.name)
        end
      end
    end
  end
}

local thbattle__huiyin_shouhu = fk.CreateTriggerSkill {
  name = "thbattle__huiyin_shouhu",
  anim_type = "big",
  frequency = Skill.Limited,
  events = { fk.EventPhaseStart },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Play and
        table.find(player.room:getOtherPlayers(player), function(p)
          return p:isWounded() and p:getMark("@thbattle__huiyin_jueyi") == 0
        end) and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if room:askForSkillInvoke(player, self.name, nil, "#thbattle__huiyin_shouhu") then
      local target_p = room:askForChoosePlayers(player,
        table.map(table.filter(player.room:getOtherPlayers(player), function(p)
          return p:isWounded()
        end), Util.IdMapper), 1, 1, "#thbattle__huiyin_shouhu-choose_p", self.name, true)
      if #target_p > 0 then
        self.cost_data = target_p[1]
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local target_p = room:getPlayerById(self.cost_data)
    room:changeMaxHp(player, -1)
    room:recover({
      who = target_p,
      num = 1,
      recoverBy = player,
      skillName = self.name
    })
    if table.every(room:getOtherPlayers(target_p), function(p)
          return p.hp >= target_p.hp
        end) then
      room:handleAddLoseSkills(player, "thbattle__huiyin_jueyi")
      room:handleAddLoseSkills(target_p, "thbattle__huiyin_jueyi")
      room:setPlayerMark(player, "thbattle__huiyin_jueyi", target_p.id)
      room:setPlayerMark(target_p, "thbattle__huiyin_jueyi", player.id)
      room:setPlayerMark(player, "@thbattle__huiyin_jueyi", Fk:translate(target_p.general))
      room:setPlayerMark(target_p, "@thbattle__huiyin_jueyi", Fk:translate(player.general))
      room:setPlayerMark(player, "@!thbattle__huiyin_jueyi", 1)
      room:setPlayerMark(target_p, "@!thbattle__huiyin_jueyi", 1)
    end
  end,

}

local thbattle__huiyin_jueyi = fk.CreateTriggerSkill {
  name = "thbattle__huiyin_jueyi",
  mute = true,
  frequency = Skill.Compulsory,
  events = { fk.DamageInflicted, fk.AfterCardsMove, fk.HpRecover },
  can_trigger = function(self, event, target, player, data)
    local room = player.room
    if #table.filter(player.room.alive_players, function(p)
          return p:hasSkill(self) and p:getMark("thbattle__huiyin_jueyi") ~= 0
        end) < 2 then
      return
    end
    if player:hasSkill(self) and player:getMark("thbattle__huiyin_jueyi") ~= 0 then
      local target_p = player.room:getPlayerById(player:getMark("thbattle__huiyin_jueyi"))
      if event == fk.AfterCardsMove and player.phase ~= Player.NotActive then
        for _, move in ipairs(data) do
          if move.to == target_p.id and move.moveReason == fk.ReasonDraw and #move.moveInfo > 0 then
            room:setPlayerMark(player, "@thbattle__huiyin_jueyi", Fk:translate(target_p.general))
            room:setPlayerMark(target_p, "@thbattle__huiyin_jueyi", Fk:translate(player.general))
            return true
          end
        end
      elseif event == fk.DamageInflicted and target_p.hp > player.hp and target == player then
        room:setPlayerMark(player, "@thbattle__huiyin_jueyi", Fk:translate(target_p.general))
        room:setPlayerMark(target_p, "@thbattle__huiyin_jueyi", Fk:translate(player.general))
        return true
      elseif event == fk.HpRecover and data.who == target_p and data.skillName ~= self.name then
        room:setPlayerMark(player, "@thbattle__huiyin_jueyi", Fk:translate(target_p.general))
        room:setPlayerMark(target_p, "@thbattle__huiyin_jueyi", Fk:translate(player.general))
        return player.phase ~= Player.NotActive and player:isWounded()
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local target_p = player.room:getPlayerById(player:getMark("thbattle__huiyin_jueyi"))
    room:notifySkillInvoked(player, self.name, "support")
    if event == fk.AfterCardsMove then
      player:broadcastSkillInvoke(self.name, 3)
      for _, move in ipairs(data) do
        if move.to == target_p.id and move.moveReason == fk.ReasonDraw then
          player:drawCards(#move.moveInfo, self.name)
        end
      end
    elseif event == fk.DamageInflicted then
      player:broadcastSkillInvoke(self.name, 1)
      local damageEvent = data
      damageEvent.to = target_p
      room:damage(damageEvent)
      return true
    else
      player:broadcastSkillInvoke(self.name, 2)
      room:recover({
        who = player,
        num = data.num,
        recoverBy = player,
        skillName = self.name
      })
    end
  end,

}

thbattle__huiyin:addSkill(thbattle__huiyin_shouye)
thbattle__huiyin:addSkill(thbattle__huiyin_shouhu)
thbattle__huiyin:addRelatedSkill(thbattle__huiyin_jueyi)

Fk:loadTranslationTable {
  ["thbattle__huiyin"] = "上白泽慧音",
  ["~thbattle__huiyin"] = "这课没法教了！",
  ["#thbattle__huiyin"] = "人间之里的守护者",
  ["designer:thbattle__huiyin"] = "Rem",
  ["cv:thbattle__huiyin"] = "银子",
  ["illustrator:thbattle__huiyin"] = "和茶",

  ["thbattle__huiyin_shouye"] = "授业",
  ["$thbattle__huiyin_shouye1"] = "好好学习，学习使你快乐",
  ["$thbattle__huiyin_shouye2"] = "知之为知之，不知为不知",
  [":thbattle__huiyin_shouye"] = "出牌阶段限一次，你重铸一张牌，然后将一张牌交给一名其它角色，其选择一项：<font color='red'>>></font> 使用一张牌，<font color='red'>>></font> 重铸一张牌。",
  ["#thbattle__huiyin_shouye"] = "授业:你重铸一张牌，然后将一张牌交给一名其它角色，其选择一项：>> 使用一张牌，>> 重铸一张牌。",
  ["#thbattle__huiyin_shouye-use"] = "授业:你可以使用一张牌,取消使用则选择重铸一张牌。",
  ["#thbattle__huiyin_shouye-give"] = "授业:你将一张牌交给%src，其选择一项：>> 使用一张牌，>> 重铸一张牌。",
  ["#thbattle__huiyin_shouye-recast"] = "授业:你重铸一张牌",


  ["thbattle__huiyin_shouhu"] = "守护",
  ["$thbattle__huiyin_shouhu"] = "我绝对不会，让你们碰到那个人一根手指的！",
  ["#thbattle__huiyin_shouhu"] = "守护：你可以失去一点体力上限，令一名其它已受伤角色回复一点体力。之后，若其体力仍然是全场最低的，则你与其获得技能【<a href=':thbattle__huiyin_jueyi'><font color='red'>决意</font></a>】。",
  [":thbattle__huiyin_shouhu"] = "限定技，出牌阶段开始时，你可以失去一点体力上限，令一名其它已受伤角色回复一点体力。之后，若其体力仍然是全场最低的，则你与其获得技能【决意】。",
  ["#thbattle__huiyin_shouhu-choose_p"] = "守护：选择一名受伤的其他角色",

  ["thbattle__huiyin_jueyi"] = "决意",
  ["$thbattle__huiyin_jueyi1"] = "我不会将人类，交给你们这些妖怪的！",
  ["$thbattle__huiyin_jueyi2"] = "我将要在这个不吉利的夜晚里，保护那些人类！",
  ["$thbattle__huiyin_jueyi3"] = "这个村子，由我来守护！",
  [":thbattle__huiyin_jueyi"] = "锁定技，当你受到伤害时，若同样拥有决意的另一名角色的体力值比你高，则伤害改为由该角色承受。同样拥有决意的另一名角色于你的回合内摸牌/回复体力时，你摸相同数量的牌/回复相同的体力。",
  ["@thbattle__huiyin_jueyi"] = "决意",

}

-- 幽冥阁楼的吃货少女 西行寺幽幽子 体力：3

-- 诱死：出牌阶段限一次，你可以令一名其它角色失去一点体力，然后其于回合结束阶段回复一点体力。
--       锁定技，回合结束阶段，若你于出牌阶段没有发动过该技能，则所有体力值为1的其它角色失去一点体力。

-- 离魂：你的回合内，当一名其它角色进入濒死状态时，你摸一张牌，然后你可以与该角色拼点：
-- >> 若你赢，则将其体力上限改为1。
-- >> 若你没赢，则将其体力值改为1。

-- 反魂：锁定技，一名角色被击坠后，你可以增加一点体力上限或回复一点体力。你的手牌上限是你的体力上限。

-- KOF不平衡角色

-- （画师：和茶，CV：VV）
local thbattle__uuz = General:new(extension, "thbattle__uuz", "tho", 3, 3, 2)

local thbattle__uuz_yousi = fk.CreateActiveSkill {
  name = "thbattle__uuz_yousi",
  prompt = "#thbattle__uuz_yousi",
  mute=true,
  target_num = 1,
  target_filter = function(self, to_select, selected, selected_cards, card, extra_data,user)
    return #selected == 0 and user.id ~= to_select
  end,
  max_phase_use_time = 1,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    if player.phase == Player.Play then
      room:addPlayerMark(player, "thbattle__uuz_yousi")
    end
    player:broadcastSkillInvoke(self.name,1)
    room:notifySkillInvoked(player,self.name,"offensive")
    THB_Utility.addStatusMark(target, "@@thbattle__uuz_yousi")
    room:loseHp(target, 1, self.name)
  end
}

local thbattle__uuz_yousi_trigger = fk.CreateTriggerSkill {
  name = "#thbattle__uuz_yousi_trigger",
  frequency = Skill.Compulsory,
  mute=true,
  events = { fk.EventPhaseStart },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Finish and
        table.find(player.room:getOtherPlayers(player), function(p)
          return p.hp == 1
        end) and player:getMark("thbattle__uuz_yousi") == 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke(self.name,2)
    room:notifySkillInvoked(player,self.name,"offensive")
    for _, p in pairs(table.filter(player.room:getOtherPlayers(player), function(p)
      return p.hp == 1
    end)) do
      room:loseHp(p, 1, self.name)
    end
  end,

  refresh_events = { fk.EventPhaseEnd },
  can_refresh = function(self, event, target, player, data)
    return target==player and player:hasSkill(self) and player.phase==Player.Finish 
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    for _, p in ipairs(room.alive_players) do
      if p:getMark("@@thbattle__uuz_yousi") > 0 then
        room:recover({
          who =p,
          num = p:getMark("@@thbattle__uuz_yousi"),
          skillName = self.name,
          recoverBy = player,
        })
        THB_Utility.removeStatusMark(p, "@@thbattle__uuz_yousi",p:getMark("@@thbattle__uuz_yousi"))
      end
      if p:getMark("thbattle__uuz_yousi") > 0 then
        room:removePlayerMark(p, "thbattle__uuz_yousi")
      end
    end
    
  end
}

local thbattle__uuz_lihun = fk.CreateTriggerSkill {
  name = "thbattle__uuz_lihun",
  anim_type = "control",
  frequency = Skill.Compulsory,
  events = { fk.EnterDying },
  can_trigger = function(self, event, target, player, data)
    return target ~= player and player:hasSkill(self) and player.phase ~= Player.NotActive
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:drawCards(1, self.name)
    if not player:isKongcheng() and not target:isKongcheng() and room:askForSkillInvoke(player, self.name, nil, "#thbattle__uuz_lihun:" .. target.id) then
      local pindian = player:pindian({ target }, self.name)
      if pindian.results[target.id].winner == player then
        room:changeMaxHp(target, 1 - player.maxHp)
      else
        room:changeHp(target, 1 - target.hp, "recover", self.name)
      end
    end
  end
}
local thbattle__uuz_fanhun = fk.CreateTriggerSkill {
  name = "thbattle__uuz_fanhun",
  anim_type = "support",
  frequency = Skill.Compulsory,
  events = { fk.Deathed },
  can_trigger=function (self, event, target, player, data)
    return target~=player and player:hasSkill(self)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if not player:isWounded() or room:askForSkillInvoke(player, self.name, nil, "#thbattle__uuz_fanhun") then
      room:changeMaxHp(player, 1)
    else
      room:recover({
        who = player,
        num = 1,
        recoverBy = player,
        skillName = self.name
      })
    end
  end
}
local thbattle__uuz_fanhun_maxcards = fk.CreateMaxCardsSkill{
  name="#thbattle__uuz_fanhun_maxcards",
  fixed_func=function (self, player)
    if player:hasSkill(self) then
      return player.maxHp
    end
  end
}

thbattle__uuz_yousi:addRelatedSkill(thbattle__uuz_yousi_trigger)
thbattle__uuz_fanhun:addRelatedSkill(thbattle__uuz_fanhun_maxcards)
thbattle__uuz:addSkill(thbattle__uuz_yousi)
thbattle__uuz:addSkill(thbattle__uuz_lihun)
thbattle__uuz:addSkill(thbattle__uuz_fanhun)

Fk:loadTranslationTable {
  ["thbattle__uuz"] = "西行寺幽幽子",
  ["~thbattle__uuz"] = "果然不能饿着肚子打架呢，妖梦？妖梦~",
  ["#thbattle__uuz"] = "幽冥阁楼的吃货少女",
  ["designer:thbattle__uuz"] = "Rem",
  ["cv:thbattle__uuz"] = "VV",
  ["illustrator:thbattle__uuz"] = "和茶",

  ["thbattle__uuz_yousi"] = "诱死",
  ["$thbattle__uuz_yousi1"] = "只差一点，西行妖就能够盛开了呢~",
  ["$thbattle__uuz_yousi2"] = "优雅的绽放吧，墨染的樱花🌸~",
  [":thbattle__uuz_yousi"] = "出牌阶段限一次，你可以令一名其它角色失去一点体力，然后其于回合结束阶段回复一点体力。回合结束阶段，若你于出牌阶段没有发动过该技能，则所有体力值为1的其它角色失去一点体力。",
  ["#thbattle__uuz_yousi"] = "诱死:你可以令一名其它角色失去一点体力，然后其于回合结束阶段回复一点体力。",
  ["#thbattle__uuz_yousi_trigger"] = "诱死",
  ["@@thbattle__uuz_yousi"] = "诱死",


  ["thbattle__uuz_lihun"] = "离魂",
  ["$thbattle__uuz_lihun"] = "不如，就这样沉眠于花下好了",
  [":thbattle__uuz_lihun"] = "你的回合内，当一名其它角色进入濒死状态时，你摸一张牌，然后你可以与该角色拼点：<br/>"
      .. "<font color='red'>>></font> 若你赢，则将其体力上限改为1。"
      .. "<font color='red'>>></font> 若你没赢，则将其体力值改为1。",
  ["#thbattle__uuz_lihun"] = "离魂：你可以与%src拼点,若你赢，则将其体力上限改为1,否则，将其体力值改为1",

  ["thbattle__uuz_fanhun"] = "反魂",
  ["$thbattle__uuz_fanhun"] = "啊啦，你已经死了呢",
  [":thbattle__uuz_fanhun"] = "锁定技，一名角色被击坠后，你可以增加一点体力上限或回复一点体力。你的手牌上限是你的体力上限。",
  ["#thbattle__uuz_fanhun"] = "反魂：你可以增加一点体力上限，取消则回复一点体力",

}

return extension
